我在.NET Core + NUnit.TestLogger(https://github.com/spekt/nunit.testlogger)上有NUnit测试项目
我通过cmd在本地计算机或teamcity中运行测试:
dotnet test --logger:nunit
我得到了预期的结果:
Results File: D:\<PATH TO MY SOLUTION>\Source\Tests\TestResults\TestResults.xml
但是,如果我通过.NET CLI在Teamcity上运行测试,则不会创建TestResults.xml文件。
为什么?
也就是说,如果我通过命令行运行dotnet测试,则会创建结果文件,如果通过.NET CLI(dotnet测试),则不会创建文件
UPD:构建日志
[13:48:22][Step 3/5] dotnet.exe test MySolution.sln --logger:"nunit" @C:\teamcity-agents\BuildAgent-1\temp\agentTmp\730f901563fb4fd9b8d130e76c50cb20.rsp
[13:48:22][Step 3/5] test (5s)
[13:48:22][test] Starting: "C:\Program Files\dotnet\dotnet.exe" test MySolution.sln --logger:"nunit" @C:\teamcity-agents\BuildAgent-1\temp\agentTmp\730f901563fb4fd9b8d130e76c50cb20.rsp
[13:48:22][test] in directory: C:\teamcity-agents\BuildAgent-1\work\21fca25db91ea807
[13:48:24][test] Build started, please wait...
[13:48:24][test] Build completed.
[13:48:24][test] Test run for C:\teamcity-agents\BuildAgent-1\work\21fca25db91ea807\Source\Tests\bin\Debug\netcoreapp2.1\MySolution.dll(.NETCoreApp,Version=v2.1)
[13:48:24][test] Microsoft (R) Test Execution Command Line Tool Version 15.9.0
[13:48:24][test] Copyright (c) Microsoft Corporation. All rights reserved.
[13:48:24][test]
[13:48:24][test] Starting test execution, please wait...
[13:48:25][test] NUnit Adapter 3.13.0.0: Test execution started
[13:48:25][test] Running all tests in C:\teamcity-agents\BuildAgent-1\work\21fca25db91ea807\Source\Tests\bin\Debug\netcoreapp2.1\MySolution.dll
[13:48:25][test] NUnit3TestExecutor converted 54 of 54 NUnit test cases
...
[13:48:27][test] Total tests: 52. Passed: 52. Failed: 0. Skipped: 0.
[13:48:27][test] Test Run Successful.
[13:48:27][test] Test execution time: 2,8774 Seconds
[13:48:27][test]
[13:48:27][test] Build succeeded.
[13:48:27][test] 0 Warning(s)
[13:48:27][test] 0 Error(s)
[13:48:27][test]
[13:48:27][test] Time Elapsed 00:00:03.96
[13:48:27][test]
[13:48:27][test] Process exited with code 0
答案 0 :(得分:0)
答案 1 :(得分:0)
我已经找到了解决方案。 首先@p4ulinux 答案有效,但在这种情况下,您错过了与 TeamCity 的集成,因此测试用例不会出现在“测试”选项卡中。 所以,我的解决方案是在 .runsettings 文件中添加下一行:
<LoggerRunSettings>
<Loggers>
<Logger friendlyName="nunit" enabled="True">
<Configuration>
<LogFileName>test-result.xml</LogFileName>
</Configuration>
</Logger>
</Loggers>
然后在设置文件部分指出您的 .runsettins 在步骤设置中的位置:
结果文件将出现在 .csproj 文件旁边的 TestResults 文件夹中。
这对我很有用!希望它对其他人有用!