NUnit 3.2.0 控制台执行

NUnit 3.2.0 Console Execution

我正在尝试从 nunit 控制台 运行 多个类别。在 3.0 以下的版本中,我 运行 将其设置为

nunit.exe "mydll.dll" /运行 /include=Category1,Category2

我想通过 nunit 3.2.0 类似地使用它。知道我该如何使用它吗?我知道 /include 选项在上面的 3.0 版本中已被替换,应该用作 --where。这是我尝试 运行 的方法。

以下是尝试过但没有成功的选项。

nunit3-console.exe "mydll.dll" --where:cat==Category1,Category2
nunit3-console.exe "mydll.dll" --where:cat==Category1&&Category2
nunit3-console.exe "mydll.dll" --where:cat==Category1||Category2

有人可以帮我一次性执行多个类别吗?

要将多个条件连接在一起,您需要每个条件都是实际条件 - 所以我认为您需要:

--where:cat==Category1||cat==Category2

或更易读的海事组织:

"--where:cat == Category1 || cat == Category2"

引用 可能 是阻止 shell 期待“|”的必要条件也很重要。

这对我来说很好用。演示:

using NUnit.Framework;

public class TestDemo
{
    [Test, Category("X")]
    public void TestX()
    {
    }

    [Test, Category("Y")]
    public void TestY()
    {
    }

    [Test, Category("Z")]
    public void TestZ()
    {
    }
}

编译:

csc /target:library /r:nunit.framework.dll TestDemo.cs

运行:

nunit3-console.exe TestDemo.dll "--where:cat==X || cat==Y"

结果:

Test Count: 2, Passed: 2, Failed: 0, Inconclusive: 0, Skipped: 0