views:

157

answers:

4

When I run my tests in Visual Studio individually, they all pass without a problem. However, when I run all of them at once some pass and some fail. I tried putting in a pause of 1 second in between each test method with no success.

Any ideas? Thanks in advance for your help...

+2  A: 

It's very possible that some modifications/instantiations done in one test affect the others. That indicates poor test design and lack of proper isolation.

Diadistis
+3  A: 

It's possible that you have some shared data. Check for static member variables in the classes in use that means one test sets a value that causes a subsequent test to fail.

You can also debug unit tests. Depending on the framework you're using, you should be able to run the framework tool as a debug start application passing the path to the compiled assembly as a parameter.

Neil Barnwell
A: 

as per the other responses. It sounds like you have a singleton or a global variable that is causing the interaction.

Fortyrunner
+2  A: 

Everyone is probably right, some shared date is being modified between tests. But note the order of MS Test execution. Simply pausing between tests is not a solution. Each test is executed in it's own instance of the test class on a separate thread.

Anthony Mastrean