سؤال

I have searched for a while and can't find an answer on here for the first time ever.

I have a solution which contains multiple C# projects. Two of these projects are unit test projects. I am building this solution with Jenkins, attempting to run all the unit tests, then packaging it for an internal NuGet server.

The issue I am having is that I am running the tests for one unit test project after the other, I think this is causing the second set of tests to save their results over the first set because I can see in the console output that both sets of tests ran and passed, however the Test Results in Jenkins only shows the second set of tests.

I am running these with a windows batch command using nunit-console like this:

nunit-console.exe MyFirstProject.UnitTests/bin/Debug/MyFirstProject.UnitTests.dll
nunit-console.exe MySecondProject.UnitTests/bin/Debug/MySecondProject.UnitTests.dll

Is there a better way I can run these so that all test results are recorded?

Thanks!

هل كانت مفيدة؟

المحلول

Figured it out. For anyone who runs into this it's quite simple, you just have to put both (or however many) assemblies in the same command like this:

nunit-console.exe MyFirstProject.UnitTests/bin/Debug/MyFirstProject.UnitTests.dll MySecondProject.UnitTests/bin/Debug/MySecondProject.UnitTests.dll

Now all my test results show up!

نصائح أخرى

As an addition to anyone else who has this type of issue:
To get one report from two groups of tests run from the same assembly, define two Windows Batch Command build steps, each with its own category and result file :

"%nunit%\nunit-console.exe" "%WORKSPACE%\MyTests.sln" /include:TestCategory1 /xml=nunit-result1.xml  

and

"%nunit%\nunit-console.exe" "%WORKSPACE%\MyTests.sln" /include:TestCategory2 /xml=nunit-result2.xml 

Add a Post Build action to Publish the NUnit Test result report and define the XML filename as *.xml.

The Nunit plugin will concatenate the different test results into one result that can be viewed and emailed.

This way will also solve the OP's question.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top