3
votes

In Jenkins I create a Visual studio project using MSBuild. After the build I execute a windows batch command that executes the tests en sets the output file.

Post build I publish the .trx test report file. This all works perfect, the only problem is that if a test fails the build fails. With other types of projects if a test fails the build only becomes unstable.

How can I do the same for my Visual studio project?

Below my batch command:

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

1

1 Answers

0
votes

I know it's pretty old but here are something as I've encountered the same type of problem.

Using Batch:
At the end of that batch command step where you run the tests, add one more exit command, such as exit /b 0 or exit 0.


Using Powershell:
At the end of the powershell command step where you run the tests, same, manually set the exit code $LastExitCode = 0.


Final:
The result will always be set to success no matter how many tests failed so you need to parse and analyze the result yourself. There are tools such as: https://plugins.jenkins.io/mstest and https://plugins.jenkins.io/xunit.