Error trying to run mstest on jenkins Error trying to run mstest on jenkins jenkins jenkins

Error trying to run mstest on jenkins


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!


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 /nologoEXIT /B 0


In the end I gave up on configuring the MSTest through the easy panels - it would not find the test dll, so like the guy above I used the batch command. I have added my batch command below because it addresses some issues with previous answers that they do not take into account that you have to delete the .trx file before each run, or give it a unique name or tests will fail.

Here is my solution running in Jenkins as a batch command:

"C:Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/MSTest.exe" /resultsfile:"%WORKSPACE%/MyAppTest_%BUILD_NUMBER%.trx" /testcontainer:"%WORKSPACE%/Components/ebox2/Central/MyApp/MyAppWeb/trunk/MyAppTest/bin/Release/MyAppTest.dll" /nologo /category:Build

Note the inclusion of %BUILD_NUMBER% in the .trx file name, which gets round the problem of jobs failing because of duplicate .trx file.

Note also that /category:Build allows you to choose the tests you want. You set up the category in the tests themselves:

[TestCategory("Build"), TestMethod()] 

I use this because I have some Selenium tests which I have not figured out how to run in Jenkins yet, or if this is possible.