Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error trying to run mstest on jenkins

Tags:

I´m trying to configure MSTest build plugin on jenkins, but I´m getting the following error:

Path To MSTest.exe: mstest.exe Result file was not found so no action has been taken. file:/C:/Program%20Files%20(x86)/Jenkins/jobs/SoftwrenchvNext/workspace/TestResult.trx FATAL: null java.lang.NullPointerException     at org.jenkinsci.plugins.MsTestBuilder.perform(MsTestBuilder.java:144) 

The configuration simply specifies TestResult.trx as ResultFileName. This file is not versioned, and I expect it to be created on each build.

What needs to be done for that?

like image 404
Luiz Henrique Martins Lins Rol Avatar asked Jan 14 '14 11:01

Luiz Henrique Martins Lins Rol


People also ask

How do I run MSTest in Jenkins?

To configure a MSTest installation, go to Manage Jenkins -> Configure System (or Manage Jenkins -> Global Tool Configuration in Jenkins 2.8, possibly earlier) and add a MSTest installation. Name is mandatory. If Path to MSTest is left blank, the default is MSTest.exe. MSTestRunner can be used as a build step.

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.

Which of the plugin analyzes the test execution reports files generated by MSTest and Vstest console?

The MSTest plugin analyzes the test execution reports (TRX) files generated by mstest and vstest. console. These files include a test execution summary, and detailed data about what happened during the tests execution.

Which Jenkins plugin helps to process test reports from non Java tools?

This plugin publishes test results of an execution of a testing tool in Jenkins.


2 Answers

After some investigation I was able to get MSTest to work in Jenkins by doing the following:

Select Manage Jenkins

enter image description here

From within the Manage Jenkins choose Configure System

enter image description here

In Configure System you will need to find MSTest and Add your MSTest configuration

enter image description here

Enter your configuration as you see fit. Mine appears as follows:

enter image description here

Save the configuration and then go to your build project and configure the appropriate items like shown below:

enter image description here

One thing to note is that I did not follow any of the steps listed on the author's site because they didn't seem to make any sense to me. I did however read the code and spent some time digging and realized that the missing piece was in the Configure System page of Jenkins.

Cheers!

like image 178
Terry Rice Avatar answered Oct 09 '22 02:10

Terry Rice


I too had this exact same error message!

My recommendation is to replace the "Run unit tests with MSTest" step. with an "Execute Windows batch command" step. This worked for me.

Command

del TestResults.trx "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\MSTest.exe" /testcontainer:Example.Tests\bin\Debug\Example.Tests.dll /resultsfile:TestResults.trx 

Using this technique you may still use the "Publish MSTest test result report" step specifying...

Test report TRX file

TestResults.trx 

Good luck!

Also, you can "simulate" the "Continue on failed tests" functionality with an "EXIT" call, seen below.

del TestResults.trx "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\MSTest.exe" /testcontainer:Example.Tests\bin\Debug\Example.Tests.dll /resultsfile:TestResults.trx /nologo EXIT /B 0 
like image 30
sky-dev Avatar answered Oct 09 '22 01:10

sky-dev