使 NUnit 具有独特的结果 <mytest1>.xml 而不是 TestResult.xml

Make NUnit have unique results <mytest1>.xml instead of TestResult.xml

我遇到一种情况,可能会在同一个虚拟机上触发多个 NUnit 控制台运行程序。

如何唯一命名我的 TestResult.xml 文件?

I do not see an option for this in the docs.


到目前为止,我的解决方案是动态创建 --work= my_folder
其中 my_folder 是用唯一编号生成的,并在批处理文件中像这样替换:

set id=%random%_%time%
start "Tests" /D "C:\NUnit.ConsoleRunner.3.7.0\tools\" "nunit3-console.exe" "C:\My_Solution\My_Tests\My_Tests.dll" "--work=C:\test-results\%id%"
powershell "C:\scripts\parse_test.ps1 %id%"

接下来,我在 PowerShell 脚本中使用该参数来解析正确的测试。
给 TestResult.xml 一个唯一的名称会容易得多。

如何更改该名称?

nunit3-console的--result选项用于设置结果文件的名称和路径。如果您使用相对路径,它会相对于您使用 --work 选项指定的目录进行保存。

但是,实际上没有内置工具可以生成唯一的名称或路径。