C# integration test status "not run" when authorization returns forbidden

Solution 1:

Troubleshooting a similar testing issue (a test that wasn't being consistently rerun) helped me discover the answer.

The cause of both issues was an exception being thrown by the console.writeline, but the IDE wasn't actively flagging it, only logging it, therefore somewhat obscuring the issue from view.

The writeline value parameter was only whitespace when the endpoint call was forbidden, causing a System.ArgumentException: The parameter cannot be null or empty. A small tweak to the code prevents the exception from occurring and provides a correct pass result.

Here was the code before:

enter image description here

And here was the code afterwards:

enter image description here

The takeaway here - if running tests in visual studio, and you're getting odd behaviour like tests that run but don't provide an outcome, or tests that ran once but don't on a rerun, check the test runner output - there may be errors hiding away there!