1
votes

We have a solution file with some 20 projects, about half of them test projects. Until recently, we used NUnit exclusively, but now we've started introducing xUnit as well (for reasons not relevant to the question). In total there are about 1800 tests, so porting them all in one go is not an option - we must make a mix of NUnit and xUnit work with our TeamCity CI/CD pipelines.

Before even adding an xUnit build configuration step to the TeamCity project, I checked in and pushed a commit that added a few xUnit tests in a new project. That made the NUnit step fail with the log output at the bottom of the question, and - importantly - aborted test running even for the remaining NUnit assemblies.

How do I configure TeamCity to run both NUnit and xUnit tests from the same set of assemblies, ignoring assemblies where no tests are found?

Log output as promised:

Starting: C:\TeamCity- Agent\work\cecd2801408764e0\packages\NUnit.ConsoleRunner.3.7.0\tools\nunit3-console.exe C:\TeamCity-Agent\temp\buildTmp\bBDbo6pa0lGnLMZYjY7WcvIGUDDIvWI7.nunit --result=C:\TeamCity-Agent\temp\buildTmp\bBDbo6pa0lGnLMZYjY7WcvIGUDDIvWI7.nunit.xml --noheader --framework=net-4.0
[11:08:59]  [Step 4/4] in directory: C:\TeamCity-Agent\work\cecd2801408764e0\My.xUnit.Tests\bin\Release
[11:08:59]  [Step 4/4] Runtime Environment
[11:08:59]  [Step 4/4] OS Version: Microsoft Windows NT 6.3.9600.0
[11:08:59]  [Step 4/4] CLR Version: 4.0.30319.42000
[11:08:59]  [Step 4/4]
[11:08:59]  [Step 4/4] Test Files
[11:08:59]  [Step 4/4] C:\TeamCity-Agent\temp\buildTmp\bBDbo6pa0lGnLMZYjY7WcvIGUDDIvWI7.nunit
[11:08:59]  [Step 4/4]
[11:09:00]  [Step 4/4]
[11:09:00]  [Step 4/4] Errors, Failures and Warnings
[11:09:00]  [Step 4/4]
[11:09:00]  [Step 4/4] 1) Invalid : C:\TeamCity-Agent\work\cecd2801408764e0\My.xUnit.Tests\bin\Release\My.xUnit.Tests.dll
[11:09:00]  [Step 4/4] No suitable tests found in 'C:\TeamCity-Agent\work\cecd2801408764e0\My.xUnit.Tests\bin\Release\My.xUnit.Tests.dll'.
[11:09:00]  [Step 4/4] Either assembly contains no tests or proper test driver has not been found.
[11:09:00]  [Step 4/4]
[11:09:00]  [Step 4/4] Test Run Summary
[11:09:00]  [Step 4/4] Overall result: Failed
[11:09:00]  [Step 4/4] Test Count: 0, Passed: 0, Failed: 0, Warnings: 0, Inconclusive: 0, Skipped: 0
[11:09:00]  [Step 4/4] Start time: 2017-10-31 10:08:59Z
[11:09:00]  [Step 4/4] End time: 2017-10-31 10:09:00Z
[11:09:00]  [Step 4/4] Duration: 0.494 seconds
[11:09:00]  [Step 4/4]
[11:09:00]  [Step 4/4] Results (nunit3) saved as C:\TeamCity-Agent\temp\buildTmp\bBDbo6pa0lGnLMZYjY7WcvIGUDDIvWI7.nunit.xml
[11:09:00]  [Step 4/4] Process exited with code -2
1

1 Answers

1
votes

You can configure NUnit to skip assemblies without tests by adding --skipnontestassemblies to the "Additional command line parameters" section.