Search code examples
jenkinsmsbuildmstest

Error trying to run mstest on jenkins


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?


Solution

  • 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