Integrating v2 with Jenkins

Here at Trov, we're all fans of for testing C# apps and our new (super-secret) project is going to use Jenkins for Continuous Integration. We've had some issues in the past with TeamCity/Github integration and since our Android team is on Jenkins we thought we'd give it a shot.

Unfortunately there aren't any plugins for running tests in Jenkins nor is there any support for reporting the results via the xUnit plugin. We took some time yesterday to remedy both problems.

Running xUnit v2 tests

  1. Since xUnit 2 has split the execution xunit.execution from the runners xunit.runners, add both NuGet packages to your project's packages.config. We chose the test project, but it doesn't really matter.

  2. The console runner xunit.console.exe requires that the appropriate xunit.execution.dll be present in the same directory as the test DLL. Dave wrote a batch file to take care of this. Download it and add an Execute Windows batch command build task to your job which runs something like this: "%WORKSPACE%\{$ProjectRoot}\test.bat"

  3. Jenkins should now discover all projects named *.Tests in the same directory as the test.bat file and assumes that the output of the Test project will be in {ProjectName}\bin\release\{ProjectName}.Tests.dll.

At this point you should run your build and verify from the console output that xUnit is indeed running your tests.

When we have some more time, we'll look into making a proper Jenkins plugin but the batch file does the job for now :)

Reporting xUnit v2 results

The xUnit plugin requires jUnit-compatible result XMLs. We've submitted a PR that will convert the xUnit v2 XML into a jUnit one.

  1. Add a "Process xUnit test result report" build step after the "Execute Windows Batch command" step.

  2. Choose "xUnit.Net-v2" from the dropdown.

  3. Add the output file pattern

  4. Hit "Save" at the bottom of the form and run a build.

If you come across any oddities in the output, please let us know. There's only one basic test right now and we look forward to adding more.

Update: They merged this on Dec. 22 so it should be available to everyone now.