random_user
random_user

Reputation: 73

how to run ejabberd tests and write new unit tests in erlang?

How do I run ejabberd tests in the test folder? I installed rebar and made sure to have a running ejabberd server and followed the steps here to: https://docs.ejabberd.im/developer/extending-ejabberd/testing/ to run the test suite.

But I get the following error:

[ec2-user@ip-173-33-33-236 ejabberd]$CT_BACKENDS=mnesia rebar ct suites=ejabberd groups=mnesia
WARN:  Missing plugins: [rebar3_hex]
==> ejabberd (ct)
ERROR: ct_run -noshell -pa "/home/ec2-user/ejabberd/ebin" 
"/home/ec2-user/ejabberd/deps/jose/ebin" "/home/ec2-user/ejabberd/deps/idna/ebin" 
"/home/ec2-user/ejabberd/deps/yconf/ebin" "/home/ec2-user/ejabberd/deps/jiffy/ebin" 
"/home/ec2-user/ejabberd/deps/p1_utils/ebin" "/home/ec2-user/ejabberd/deps/base64url/ebin" 
"/home/ec2-user/ejabberd/deps/fast_yaml/ebin" "/home/ec2-user/ejabberd/deps/stringprep/ebin" 
"/home/ec2-user/ejabberd/deps/ezlib/ebin" "/home/ec2-user/ejabberd/deps/fast_tls/ebin" 
"/home/ec2-user/ejabberd/deps/fast_xml/ebin" "/home/ec2-user/ejabberd/deps/unicode_util_compat/ebin" 
"/home/ec2-user/ejabberd/deps/proper/ebin" "/home/ec2-user/ejabberd/deps/base16/ebin" 
"/home/ec2-user/ejabberd/deps/lhttpc/ebin" 
"/home/ec2-user/ejabberd/deps/eini/ebin" "/home/ec2-user/ejabberd/deps/jsx/ebin" 
"/home/ec2-user/ejabberd/deps/meck/ebin" "/home/ec2-user/ejabberd/deps/goldrush/ebin" 
"/home/ec2-user/ejabberd/deps/p1_mysql/ebin" "/home/ec2-user/ejabberd/deps/p1_acme/ebin" 
"/home/ec2-user/ejabberd/deps/mqtree/ebin" "/home/ec2-user/ejabberd/deps/eimp/ebin" 
"/home/ec2-user/ejabberd/deps/pkix/ebin" "/home/ec2-user/ejabberd/deps/p1_oauth2/ebin" 
"/home/ec2-user/ejabberd/deps/xmpp/ebin" "/home/ec2-user/ejabberd/deps/cache_tab/ebin"
 "/home/ec2-user/ejabberd/deps/uuid/ebin" "/home/ec2-user/ejabberd/deps/erlcloud/ebin" 
"/home/ec2-user/ejabberd/deps/lager/ebin" "/usr/local/bin/rebar/rebar/ebin" 
"/usr/local/bin/rebar" "/home/ec2-user/ejabberd/."  -include "/home/ec2-user/ejabberd/include"  
-name [email protected] -logdir 
"/home/ec2-user/ejabberd/logs" -env TEST_DIR "/home/ec2-user/ejabberd/test" 
-cover /home/ec2-user/ejabberd/cover.spec  -suite test/ejabberd_SUITE.erl 
-group mnesia -ct_hooks cth_surefire  -include /home/ec2-user/ejabberd/tools 
-include /home/ec2-user/ejabberd/include -include /home/ec2-user/ejabberd/deps/p1_utils/include 
-include /home/ec2-user/ejabberd/deps/fast_xml/include 
-include /home/ec2-user/ejabberd/deps/xmpp/include  >>
 /home/ec2-user/ejabberd/logs/raw.log 2>&1 failed with error: 1 and output:

ERROR: ct failed while processing /home/ec2-user/ejabberd: rebar_abort

How do I run these unit tests? Also, is there a recommended framework to write ejabberd/erlang unit tests? I basically want to run some specific functions in the module for various inputs and make sure the output is correct and I do need the server part running for this?

Any suggestions/pointers would be really appreciated. Thanks!

Upvotes: 1

Views: 171

Answers (1)

Badlop
Badlop

Reputation: 4120

You don't mention what ejabberd and erlang version, so I assume they are the latest available.

How do I run these unit tests?

Notice that ejabberd already includes the rebar program. So better use that one instead of whatever you have installed. I simply run this, and works correctly:

CT_BACKENDS=mnesia ./rebar ct suites=ejabberd groups=mnesia

I do need the server part running for this?

No need for ejabberd to be started when running that command. At least I stop it before running the tests...

Also, is there a recommended framework to write ejabberd/erlang unit tests? I basically want to run some specific functions in the module for various inputs and make sure the output is correct and

Sorry, no idea.

Upvotes: 0

Related Questions