如何让 Mix 只运行我的测试套件中的特定测试?
运行时 mix test
执行所有测试
最佳答案
有 5 种方法可以使用 Elixir 仅运行特定测试
mix test path_to_your_tests/your_test_file.exs
运行单个文件这将运行
your_test_file.exs
中定义的所有测试例如
mix test path_to_your_tests/your_test_file.exs:12
将在第 12 行运行测试your_test_file.exs
defmodule MyTests do
@tag disabled: true
test "some test" do
#testtesttest
end
end
在命令行上像这样执行你的测试
mix test --exclude disabled
defmodule MyTests do
@tag mustexec: true
test "some test" do
#testtesttest
end
end
在命令行上像这样执行你的测试
mix test --only mustexec
test/test_helper.exs
来排除一些标记的测试。文件ExUnit.configure exclude: [disabled: true]
警告:
Mix 有一个
--include
指示。该指令是 不是 与 --only
相同指示。 Include 用于打破 test/test_helper.exs
中的一般配置(排除) 4)中描述的文件。出于某种原因,谷歌搜索
elixir mix include tests
或类似内容从未出现在我的搜索结果中,因此我编写了此条目及其答案。欲了解更多信息,请参阅 the Mix documentation .
关于elixir - 如何让 Mix 只运行我的测试套件中的特定测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26150146/