NUnit tests don't terminate when using StopOnError flag under dotnet test

25 Views Asked by At

In our software team we are developing a suite of API tests written in C#, using NUnit and run using dotnet test. The test suite uses TestServer to exercise our API.

These tests are high(ish)-level integration tests and so are liable to cascade failure which can create a lot of noise during debugging. I've started exploring NUnit3's stoponerror flag which I'm passing in using a .runsettings file as detailed here.

When I run an individual test the test runner terminates on the first failure, as expected. However, when I run the entire suite of tests the test runner doesn't terminate, but hangs on the first test failure.

I've scoured the internet high and low, and can't find out what's going on so would be grateful if any folks out there have experienced something similar and what worked for you.

I've verified that stoponerror works perfectly for a single test, or even for a couple of tests. However, it seems to me that if a test class falls alphabetically after the test class which fails, then the test runner hangs. Weird!

Have tried updating to the latest NUnit, NUnit3TestAdapter and Microsoft.NET.Test.Sdk packages, but that didn't help.

Have also tried experimenting with the SingleThreaded attribute, as I did wonder if the tests might be running on separate threads and if that would make a difference, but no cigar. Am truly stumped!

0

There are 0 best solutions below