我正在尝试测试从磁盘加载文件并对其进行一些操作的函数。我的项目分为src/和test/目录。我将测试文件放在test/目录下,并尝试运行加载此文件的单元测试。但是,在使用rebar从IDE (IntelliJ)或控制台运行测试时,文件似乎不可见。
$ ./rebar eunit
==> traffic-emas (eunit)
input_test: load_from_file_test...*failed*
in function input:load_intersection_definition/1 (src/input.erl, line 40)
in call from input_test:load_from_file_test/0 (test/input_test.erl, line 14)
**error:{badmatch,{error,enoent}}我应该将eunit的测试文件放在哪里以使其可见?
发布于 2016-02-25 02:36:06
您可以在eunit测试中打印出工作目录,并查看它认为正在运行的位置:
debugVal(file:get_cwd())这应该给你一个好的想法,把它放在哪里。
发布于 2016-02-21 22:36:26
钢筋的文件显示,您应该在模块本身中放置一个特定于模块的eunit测试。例如:
-ifdef(TEST).
simple_test() ->
ok = application:start(myapp),
?assertNot(undefined == whereis(myapp_sup)).
-endif.https://stackoverflow.com/questions/35540331
复制相似问题