Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing in Visual Studio Succeeds Individually, Fails in a Set

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...

like image 825
Matt McCormick Avatar asked Dec 30 '08 13:12

Matt McCormick


3 Answers

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.

like image 174
Neil Barnwell Avatar answered Sep 19 '22 04:09

Neil Barnwell


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.

like image 29
Diadistis Avatar answered Sep 22 '22 04:09

Diadistis


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.

like image 37
Anthony Mastrean Avatar answered Sep 23 '22 04:09

Anthony Mastrean