如何运行 ejabberd 测试并在 erlang 中编写新的单元测试?
Posted
技术标签:
【中文标题】如何运行 ejabberd 测试并在 erlang 中编写新的单元测试?【英文标题】:how to run ejabberd tests and write new unit tests in erlang? 【发布时间】:2020-05-31 23:30:40 【问题描述】:如何在测试文件夹中运行 ejabberd 测试? 我安装了 rebar 并确保有一个正在运行的 ejabberd 服务器,并按照此处的步骤: https://docs.ejabberd.im/developer/extending-ejabberd/testing/ 运行测试套件。
但我收到以下错误:
[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 test2876@ip-172-31-32-236.us-east-2.compute.internal -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
如何运行这些单元测试? 另外,是否有推荐的框架来编写 ejabberd/erlang 单元测试? 我基本上想在模块中为各种输入运行一些特定功能并确保输出正确,我确实需要为此运行服务器部分吗?
任何建议/指针将不胜感激。谢谢!
【问题讨论】:
【参考方案1】:你没有提到 ejabberd 和 erlang 版本,所以我认为它们是最新的。
如何运行这些单元测试?
请注意,ejabberd 已经包含 rebar 程序。所以最好使用那个而不是你安装的任何东西。我只是运行它,并且工作正常:
CT_BACKENDS=mnesia ./rebar ct suites=ejabberd groups=mnesia
我确实需要为此运行服务器部分吗?
运行该命令时无需启动 ejabberd。至少我在运行测试之前停止它......
另外,是否有推荐的框架来编写 ejabberd/erlang 单元测试?我基本上想在模块中为各种输入运行一些特定的功能,并确保输出正确并且
抱歉,不知道。
【讨论】:
以上是关于如何运行 ejabberd 测试并在 erlang 中编写新的单元测试?的主要内容,如果未能解决你的问题,请参考以下文章
Erlang epmd 问题 - RabbitMQ 和 Ejabberd 在同一主机上
格式:“读取 /opt/ejabberd/.erlang.cookie 时出错:eacces”