Reputation: 45295
I know that all test should be independent and run in the random order.
But here is my situation:
I need to test my library which is working with external web resource. I have one test which checks if the web resource available and I have many tests which check the data I get from this resource.
If the web resource is not available I have all my tests failed and I think it is difficult to interpret this result. Is there any way to run all tests which check the data I get from resource if and only if the first test (which checks resource availability) was not failed?
Upvotes: 1
Views: 118
Reputation: 236218
I think availability of web resource should be a precondition for tests of your library. It should not be a separate test itself.
So, you need to check connection in TestFixtureSetup. If connection fails, all tests from fixture will not run. All tests in this test fixture will be marked as failed (which is true if there is no connection) and you will receive message
TestFixtureSetUp failed in YourLibtraryTests
Unfortunately NUnit will not show additional information if you will fail test with some message
Assert.NotNull(connection, "Cannot establish connection to remote service");
But it will be easy to find the reason if you know that TestFixtureSetUp failed.
Upvotes: 4