Tuesday, May 05, 2020

Part 2 : Using Jenkins to build .Net Core and NUnit



Run NUnit tests from Jenkins



This blog walks you through setting Jenkins up for hooking Nunit tests. 


Enable the MSTest plugin


In this step, you will learn how to install the MSTest plugin.
  • Once on the main page of Jenkin's you will need to navigate to Manage Jenkins in the left-hand navigation.
  • Then click on Manage Plugins like below.
  • Once on the main page of Jenkin's you will need to navigate to Manage Jenkins in the left-hand navigation.
  • Then click on Manage Plugins like below.
  • Then click on the Available tab.
  • Check the MSTest checkbox under .NET Development.
  • Scroll down and click on "Download now and install after restart".


Adding NUnit to project configuration



  • In your project go to Configure > Build 
  • Add a build step
  • In the dropdown scroll down to Execute Windows Batch Command
  • Ensure this step is placed after your MSBuild step
  • Add the following, replacing the variables with exact path to the files. 

dotnet test [fullpath]\NUnitTestApplication.dll --logger "trx;LogFileName=TestResults.trx"




Adding Post Build Test results 


  • In your project go to Configure.  
  • Add post-build action > Publish MSTest test result report. 
  • You can leave everything else as is like below.




Report 



You should now be able to see the results of your test like below 







No comments: