Building a Build Server – Executing Unit Tests as Part of the Build

In this article, we are going to configure our Jenkins build server to execute the unit tests in the project during the build. Thus, if the unit tests fail but the code compiles, the build will be marked as unstable. The NUnit plugin, displaying the test results, also lets us to review test statistics compared between builds.

The Jenkins installation that we are going to use, already has the following components set up:

During the example, we are going to build our favorite test project, JenkinsHelloWorld. This project is located at Feel free to us any other project, if you are not afraid to investigate project problems during the Jenkins setup. As an alternative solution, you can follow along with the test project and then switch your known to work Jenkins configuration to build your project.

Installing NUnit console runner on the build server

Log on into the build server, open a Cygwin terminal and execute the following commands:

cd /tmp






cd /tmp

mv /cygdrive/c

cd /cygdrive/c

icacls /T /Q /C /RESET

Install the NUnit plugin

Having the NUnit plugin installed on Jenkins, will provide the opportunity to analyze the test results. To do this, open your main Jenkins page, go to the Manage Jenkins / Manage Plugins menu, and in the Available section select the NUnit plugin and install it.

Configure the test project

Create a new project in Jenkins named NUnitHelloWorld. For the project template use Freestyle project. The configuration of the project is the following:

Source Code Management

Use Git source code management with


Repository URL


Branches to build

Branch specifier (blank for ‘any’)


Repository browser:



Build a Visual Studio project or solution using MSBuild

MSBuild version

MSBuild 14.0

MSBuild file



Execute NAnt build

NAnt Version


NAnt Build File




Post-build Actions

Publish NUnit test result report

Test report XMLs



Next time, we are going to set up our build server to mark assemblies with the build number, so that we can identify later, which build was executed when a problematic binary is investigated for bugs. Please share if you find this article useful. For updates, you can follow me on Twitter or LinkedIn.

By subscribing to the email list, you will be notified about new posts.
No comments yet.

Leave a Reply

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

Powered by WordPress. Designed by WooThemes