在Erlang/OTP中使用Eunit是否有一种只在单个模块中运行单元测试的方法?
我有很多单元测试模块。有没有办法只在单个模块中运行单元测试 这是本模块相关部分的内容:在Erlang/OTP中使用Eunit是否有一种只在单个模块中运行单元测试的方法?,erlang,eunit,Erlang,Eunit,我有很多单元测试模块。有没有办法只在单个模块中运行单元测试 这是本模块相关部分的内容: -export([ ..... ]) -include_lib("eunit/include/eunit.hrl"). ... ... ... first_test() -> ... ... second_test() -> ... ... eunit:test(yourmodule)或yourmodule:test()应该可以工作。您还可以使用: reba
-export([ ..... ])
-include_lib("eunit/include/eunit.hrl").
...
...
...
first_test() ->
...
...
second_test() ->
...
...
eunit:test(yourmodule)
或yourmodule:test()
应该可以工作。您还可以使用:
rebar clean eunit suite=your_module
运行模块/套件中的所有测试(如iuriza的回答): 或者您也可以指定单个测试用例(按函数名): 参考资料:
rebar3
,您可以根据他们的文档使用--module
选项
rebar3 eunit--module=您的_模块
如果您有很多模块,但只想对其中几个模块运行测试,则可以使用逗号分隔名称:
rebar3 eunit--module=第一个模块、第二个模块、第三个模块
文档中有很多将测试运行限制为单个应用程序、文件等的技巧。改进了Adam Linberg的响应,我做到了:
rebar3 as test shell
这使得编译单元测试文件成为可能。然后您可以键入:
eunit:test(yourmodule)
或
关于运行测试的rebar3 eunit文档:
rebar3 as test shell
eunit:test(yourmodule)
yourmodule:test()