How to run xUnit tests on Jenkins

Jenkins does not support running of xUnit tests out of the box. So that you need to run it manually and import test results to Jenkins. This quick manual shows how to do this.

  1. Add xunit console runner to your test projects. You should add the package “xunit.runner.console” from NuGet and you’re done. You will use it to run your tests.
  2. Install “xUnit Plugin” to your Jenkins. This plugin will be used to import tests results to Jenkins.
  3. (Optional) Install “Test Results Analyzer Plugin” to your Jenkins. It will show cool summary about tests.
  4. Add “Execute Windows batch command” as a step to your Jenkins job.
    <xunit-runner-path>\xunit.console [list-of-dll] -xml <xunit-testresults-path>\yourproject-xunit-results.xml

    <unit-runner-path> – the folder containing the file xunit.console.exe. It should be located in the “packages” folder of your project somewhere at location “<project_root>\packages\xunit.runner.console.2.2.0\tools\”
    <xunit-testresults-path> – some folder where you’d like to store the file with results. It might be the root project folder.

  5. Add Post-build Action “Publish xUnit test result report” and choose “xUnit.Net-v2 (default)”: **/yourproject-xunit-results.xml

At this point you should be able to see results of tests in Jenkins. You can make other modifications to improve Jenkins configuration.

  1. Add variable to xunit console to use shortcut in commands
  2. Write power shell script to automaticaly pick all DLLs with tests

See Also


Tags: ,

One thought on “How to run xUnit tests on Jenkins”

  1. I tried the steps provided but I am always getting an error saying “System.InvalidOperationException: Unknown test framework: could not find xunit.dll (v1) or xunit.execution.*.dll (v2) in Jenkins workspace”. Please help!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Post

%d bloggers like this: