如何使用 nunit 控制台运行器从命令行运行多个测试?

时间:2021-06-10 20:49:34

标签: jenkins nunit

当我尝试使用以下语法从 Jenkins 或本地命令行运行时,我有失败的测试列表(属于不同的类、命名空间)

.\packages\NUnit.ConsoleRunner.3.10.0\tools\nunit3-console.exe --where test==failedTest1,failedTest2,failedTest3 .\ABCTesting\bin\Debug\Api.IntegrationTesting.dll< /strong>

输出 运行设置 DisposeRunners:真 工作目录:C:\API_IntegrationTesting 图像运行时版本:4.0.30319 ImageTargetFrameworkName: .NETFramework,Version=v4.7.2 ImageRequiresX86:错误 ImageRequiresDefaultAppDomainAssemblyResolver: False 测试工人数:12

测试运行总结 总成绩:通过 测试计数:0,通过:0,失败:0,警告:0,不确定:0,跳过:0 开始时间:2021-06-10 20:43:49Z 结束时间:2021-06-10 20:43:52Z 持续时间:2.574 秒

1 个答案:

答案 0 :(得分:0)

您的 where 子句的语法有两个基本问题...

  1. 逗号 (',') 在 where 子句中没有作用。因此,您告诉 NUnit 查找名为“failedTest1,failedTest2,failedTest3”的测试。很可能<g>您没有使用该名称的测试。

  2. test 操作数指定为测试的 FullName,即命名空间和实际测试名称。

因此,您示例中的正确语法可能是...

--where "test==My.Namespace.failedTest1 || test==My.Namespace.failedTest2 || test==My.Namespace.failedTest3"

作为替代方法,您可能需要考虑使用 --testlist 选项,它允许您将测试名称放在文本文件中,每行一个全名。