有没有办法在 Erlang/OTP 中使用 Eunit 仅在单个模块中运行单元测试?
我有许多带有单元测试的模块。有没有办法只在单个模块中运行单元测试?
该模块的相关部分如下所示:
-export([ ..... ])
-include_lib("eunit/include/eunit.hrl").
...
...
...
first_test() ->
...
...
second_test() ->
...
...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
运行模块/套件中的所有测试(如 iuriza 的答案):
或者您也可以指定单个测试用例(按函数名称):
参考文献:
https://rebar3.org/docs/testing/eunit/
Run all tests in the module/suite (as iuriza's answer):
Or you can also specify an individual test case (by function name):
References:
https://rebar3.org/docs/testing/eunit/
eunit:test(yourmodule)
或yourmodule:test()
应该可以工作。eunit:test(yourmodule)
oryourmodule:test()
should work.如果您使用的是
rebar3
,您可以根据其 运行测试 doc.如果您有大量模块,但只想运行其中几个模块的测试,则可以用逗号分隔名称:
文档中有很多关于将测试运行限制为单个应用程序、文件等的提示。
If you're using
rebar3
you can use the--module
option per their Running Tests doc.If you have tons of modules, but only want to run tests for a few of them, you can separate the names with commas:
The documentation has a lot of tips for limiting the tests run to a single application, file, etc.
您还可以使用:
You could also use:
改进 Adam Linberg 的响应,我做了:
这使得编译单元测试文件成为可能。然后您可以输入:
或
Improving on the response from Adam Linberg, I did:
which makes possible to compile unit test files. Then you can type:
or