2014-10-01 111 views

回答

33

有5种方法来与灵药只运行特定的测试

  1. 运行与mix test path_to_your_tests/your_test_file.exs
    这是一个单一的文件将运行在your_test_file.exs

    定义的所有测试
  2. 通过添加冒号和该测试的行号,从特定测试文件运行特定测试
    例如mix test path_to_your_tests/your_test_file.exs:12将以 your_test_file.exs

  3. 线12运行测试定义标签在命令行上的测试方法

    defmodule MyTests do 
        @tag disabled: true 
        test "some test" do 
         #testtesttest 
        end 
    end 
    

    排除执行你的测试,这样
    mix test --exclude disabled

  4. 定义要包含在您的测试方法上的标签

    defmodule MyTests do 
        @tag mustexec: true 
        test "some test" do 
         #testtesttest 
        end 
    end 
    
    在命令行上

    执行这样
    mix test --only mustexec

  5. 您的测试一般通过添加以下内容到test/test_helper.exs文件
    ExUnit.configure exclude: [disabled: true]

ACHTUNG 排除某些标记测试Mix有一个--include directiv即该指令是NOT--only指令相同。包含用于打破4)中描述的test/test_helper.exs文件的一般配置(排除)。

由于某种原因,Google搜索elixir mix include tests等搜索结果从未出现,因此我已撰写此条目及其答案。文档可以在这里找到
http://elixir-lang.org/docs/stable/mix/

+7

你也可以这样做:'混合测试路径/到/文件:行',它会在那个文件中运行测试。 – 2014-10-02 07:57:53

+0

robkuz,您可以将此答案标记为已接受。 – 2014-12-11 11:35:49

相关问题