2
我为我的Elixir项目编写了一些测试,并将它们放在test/
目录中。现在,我跑mix test
,我得到:混合测试 - 测试模式不匹配任何文件
$ mix test
Test patterns did not match any file:
就是这样,以后什么都没有。 我是否必须手动设置我的测试路径? Google快速搜索没有发现任何内容。
这是我所有的测试看起来像:
# 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
是的,这是可能的 - 运行'混合帮助测试'并参见块配置。 ':test_paths' - 包含测试文件的路径列表,默认为 '[“test”]'。预计所有测试路径都包含一个'test_helper.exs'文件。 ':test_pattern' - 加载测试文件的模式,默认为'* _test.exs'。 –
是否有原因要改变测试路径而不是使用默认值?运行'混合新'应该给你一个好脚手架。除非有一个令人信服的理由,为什么您需要让文件不以* _test.exs结尾,我认为最好保持默认值。保持它的惯用和所有 – Kevin