Problems running NUnit tests
-
This might not be the best forum for this question but I hope someone will be able to answer it anyway. I have a bunch of nunit tests that I want to run. The problem is that they fail if run them all. If I run them one by one they work fine. These tests tests some sockets network code. The network connection is done using a static object. This means all tests use the same network connection object. I thought that the tests run one after the other, but it seems they run in parallell sometimes. This has the effect that a test connects to the server and starts doing what the test does and then another test opens a new connection with the effect that the state needed in the first tests is lost, and thereby causing the first test to fail. So the real question is how NUnit runs the tests? Does it run them one after the other or (atleast to some degree) in parallell?
-
This might not be the best forum for this question but I hope someone will be able to answer it anyway. I have a bunch of nunit tests that I want to run. The problem is that they fail if run them all. If I run them one by one they work fine. These tests tests some sockets network code. The network connection is done using a static object. This means all tests use the same network connection object. I thought that the tests run one after the other, but it seems they run in parallell sometimes. This has the effect that a test connects to the server and starts doing what the test does and then another test opens a new connection with the effect that the state needed in the first tests is lost, and thereby causing the first test to fail. So the real question is how NUnit runs the tests? Does it run them one after the other or (atleast to some degree) in parallell?
I've not noticed them running in parallel and I don't believe that they do but I have had similar problems and upon closer inspection determined that I have introduced some state dependencies. Anyway, the solution for me was to use Setup and Teardown (Nunit things) code to make sure state was setup correctly for each test that I ran. That just might work for you too.