【发布时间】:2021-05-21 07:45:18
【问题描述】:
我尝试在 NUnit 中使用 Combinatorial/Values 属性。
虽然它在本地工作,但在运行 NUnit 2.6.2 的 TeamCity 构建中会跳过带有这些属性的测试——构建报告表明该测试被忽略,但没有提供任何关于忽略它的原因的详细信息。
根据the documentation,Combinatorial 属性(以及Values 属性)存在于 NUnit 2.5 中,因此我希望它在 NUnit 2.6 中仍受支持。
为什么会忽略测试?
这是重现该问题的最基本示例。在本地,两个测试都运行并给出完全相同的结果。在 TeamCity 上,只有 Test1 被执行,Test2 被标记为忽略。
[TestCase("a", "1")]
[TestCase("a", "2")]
[TestCase("b", "1")]
[TestCase("b", "2")]
public void Test1(string x, string y) {
Assert.AreEqual(x + "," + y, string.Format("{0},{1}", x, y));
}
[Test, Combinatorial]
public void Test2([Values("a", "b")] string x, [Values("1", "2")] string y) {
Assert.AreEqual(x + "," + y, string.Format("{0},{1}", x, y));
}
【问题讨论】:
-
您在 TeamCity 中使用什么 runner 来运行 NUnit 测试?