Sunday 15 September 2013

visual studio 2008 - Unit test sequence when running all tests in solution -


In a complex VS2008 solution I have three unit testing projects. As soon as they work on the same test database, It is important that the test projects are executed after the second one, it is not important that the project was done before only one other has expired before it started.

If I want to execute them all, there are several ways to do this, which give birth to different results:

  • I have a test list. If the Vsmdi file is ordered by the test project, if I open the list and execute the test from the test list editor, then everything is fine.
  • If I open the test view window then sort the tests by the projects and run them, then everything is fine.
  • However, if I run the menu by selecting 'Test -> Run -> All Test In Solution', then they are executed in random order, where some of them fail, because other tests One of the projects already tampered Test DB.

So the question is, what does the unit test sequence determine when using the third approach? What is a way to specify a default test list in .testrunconfig?

As a solution, the problem is not important at all but any idea is welcome thanks.

You are facing a test test odor called Interactive Test , described More specifically in the best, you are suffering from shared fixtures , which is another way to say that many of your tests use the same shared database, and that they are the result of the previous test run Depend on

This is an anti-pattern and it should be avoided by all prices. The book provides comprehensive guidance on how to deal with this situation.

I started by telling the reason that this is the reason why MSTE does not guarantee the order of the tests. Although the order (semi) seems deterministic, you can not trust it. Some other unit testing frameworks (xUnit.NET comes into mind) Even as long as you run the test suite run run tests in a random order, MSTest is not extreme, but there is no way By which you can test your unit.

He said, if you are running a Visual Studio Team Suite or (I believe) Team Test, then one type of test is called an ordered test Execute all tests (including unit tests) in a specific order that you can use to specify.


No comments:

Post a Comment