Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I run .NET Core unit tests in Bamboo?

We have a .NET Core 2.1 unit test project, which contains a battery of NUnit tests. We are using NUnit 3.10.1.

Unfortunately, NUnit Console does not yet support .NET Core projects. So the only way to run tests in Bamboo is to use the dotnet test command:

dotnet test --logger "trx;LogFileName=testresults.trx"

So I tried doing that by running it as a command in the Bamboo build, and it does indeed run, but when it fails, it just says that the step failed, without specifying which tests caused it to fail.

I created a step to parse the test result file, but the build fails before reaching this step. So how should I set this up so that I can see the test results?

I've asked this question over on the community page at Atlassian, but I didn't get any useful responses.

like image 781
Shaul Behr Avatar asked Mar 07 '23 10:03

Shaul Behr


1 Answers

I found a workaround. It doesn't feel 100% right, but it seems to do the trick. Any better solutions are welcomed!

  1. Make a "command" task to run the dotnet test command.
  2. Make a "MS Test Parser" task to parse the test results, and (here's the essential part:) move it under "Final tasks" so the the parser executes even if the test step fails.
like image 100
Shaul Behr Avatar answered Mar 08 '23 23:03

Shaul Behr