VBAHole
VBAHole

Reputation: 1518

Fail Jenkins build when xUnit tests do not pass

I have Jenkins building my C# .NET Core api project. I added some xUnit tests and included a powershell script inside of my Jenkins build with the "dotnet test" command to execute the tests. That all works well and the tests are run and i can see the output in the Jenkins console. The problem is that if i have failing tests nothing happens - jenkins goes merrily along and finished up the build process and reports it as a success.

How can i get it to fail the build?

Is there a response from the 'dotnet test' command?

I know there are xUnit Jenkins plugins but they all seem to revolve around "display the results of xUnit tests". Which is not really what i am after. I want to ACT on the results of the tests, not just see them in fancy html.

Upvotes: 2

Views: 1335

Answers (1)

zihotki
zihotki

Reputation: 5191

You should check for the return code from dotnet test command. It returns 0 if all tests were successful and 1 if any of the tests failed. Unfortunately it's not documented but was confirmed in this issue

Upvotes: 0

Related Questions