Elixir 混合测试-测试模式与任何文件都不匹配
我为Elixir项目编写了一些测试,并将它们放在Elixir 混合测试-测试模式与任何文件都不匹配,elixir,elixir-mix,Elixir,Elixir Mix,我为Elixir项目编写了一些测试,并将它们放在test/目录中。现在我运行了混合测试,我得到: $ mix test Test patterns did not match any file: 就这样,之后什么都没有了我必须手动设置测试路径吗?谷歌快速搜索没有发现任何信息 我的所有测试都是这样的: 所有测试都应以\u test.exs结束。将我的测试从some_module.exs重命名为some_module_test.exs修复了它,现在它可以工作了 从$mix help test:
test/
目录中。现在我运行了混合测试
,我得到:
$ mix test
Test patterns did not match any file:
就这样,之后什么都没有了我必须手动设置测试路径吗?谷歌快速搜索没有发现任何信息
我的所有测试都是这样的:
所有测试都应以
\u test.exs
结束。将我的测试从some_module.exs
重命名为some_module_test.exs
修复了它,现在它可以工作了
从$mix help test
:
此任务启动当前应用程序,并加载
test/test\u helper.exs
,然后需要与
test/**/\u test.exs
并行模式
我仍然想知道是否可以手动配置测试路径(即使最后没有“test”一词)。是的,可以-运行
mix help test
并查看块配置<代码>:测试路径-包含测试文件的路径列表,默认为[“测试”]
。所有测试路径都应包含test\u helper.exs
文件:test_模式
-加载测试文件的模式,默认为*\u test.exs
。是否有原因要更改测试路径而不是使用默认路径?运行mixnew
会给你一个好的脚手架。除非有令人信服的理由说明您需要让文件不以*_test.exs结尾,否则我认为最好使用默认值。保持它的习惯性等等
# project_dir/test/my_app/some_module.exs
defmodule MyApp.SomeModule.Test do
use ExUnit.Case
doctest MyApp.SomeModule
test "method 1" do
assert MyApp.SomeModule.method_1_works?
end
test "method 2" do
assert MyApp.SomeModule.method_2_works?
end
end