Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you run NUnit tests from Jenkins?

I'm looking to run automated NUnit tests for a C# application, nightly and on each commit to svn.

Is this something that Jenkins-CI can do?
Is there an online tutorial or how-to document which documents a similar setup that I can look at?

like image 958
blueberryfields Avatar asked Feb 02 '12 23:02

blueberryfields


People also ask

Can we use Jenkins for unit testing?

Jenkins provides an out of box functionality for Junit, and provides a host of plugins for unit testing for other technologies, an example being MSTest for . Net Unit tests. If you go to the link https://wiki.jenkins-ci.org/display/JENKINS/xUnit+Plugin it will give the list of Unit Testing plugins available.


1 Answers

I needed to do exactly what you do, here's how I setup Jenkins to do this:

  1. Add the NUnit Plugin to Jenkins
  2. In your project go to Configure -> Build -> Add a build step
  3. In the dropdown scroll down to -> Execute Windows Batch Command
  4. Ensure this step is placed after your MSBuild step
  5. Add the following, replacing the variables:

Single dll test:

[PathToNUnit]\bin\nunit-console.exe [PathToTestDll]\Selenium.Tests.dll /xml=nunit-result.xml

Multiple dll test using NUnit test projects:

[PathToNUnit]\bin\nunit-console.exe [PathToTests]\Selenium.Tests.nunit /xml=nunit-result.xml

  1. Under Post-build Actions, tick Publish NUnit test result report
  2. For the textbox Test report XMLs, enter nunit-result.xml

Once you project has been built, NUNit will now run and the results will be viewable either on the Dashboard(if you hover over the Weather report icon) or on the project page under Last Test Result.

You could also run the command from within Visual Studio or as part of you local build process.

Here's two blog posts I used for reference. I didn't find any that fitted my requirements exactly:
1-Hour Guide to Continuous Integration Setup: Jenkins meets .Net (2011)
Guide to building .NET projects using Hudson (2008)

like image 176
Ralph Willgoss Avatar answered Sep 27 '22 20:09

Ralph Willgoss