How can I make a test suite only as ordered tests?

I have never done the ordered tests since I am from beleif, which is not a good practice. Where I work, they tell me to do it, so drop that good or bad practice.

I am new to msTests, so you can help me here.

I have 10 tests and they need to be run in a specific order, or some of them will fail.

  • I created a base test class and added all 10 tests.
  • I created a custom test and moved right in the order in which I want to run them. All perfectly.
  • Run the tests, but MsTest runs the tests twice. After the ordered tests, everything is successful! But the same tests are also performed in no particular order.

I am missing the obvious if I have a set of tests that are in order, if they are not removed, since regular tests run only as an ordered test.

How can I make a test suite only as ordered tests?

Any suggestions?

+6
unit-testing mstest
source share
4 answers

I also struggled with this, but then I found the following documentation on MSDN: Custom review of tests

Apparently, you will not get the list of tests in the correct order in the test view. Instead, an ordered test appears as one test.

This was not good news for me, as my tests will be executed twice when I select “Run all tests in the solution” (and do not run the second time when starting in the wrong order), but at least I got an explanation why it behaves this way.

+1
source share

In VSTS, whenever you create an ordered test, it actually creates a separate file for this test. Thus, at runtime you only need to execute this custom test file. It will include all the tests in a specific order, and at runtime it will work as per it.

+1
source share

This is a popular question (although I agree, this is a very bad practice). Check out this question:

How does the MSTEST / Visual Studio 2008 test test determine the execution order of the test method?

I did not do this myself, so I can not guarantee that any of the answers in the above question worked, but it is worth it.

0
source share

This may be an old topic for an answer, but this question arises on the first page when searching on Google. I think you are looking for a playlist. Create a new test playlist, and then add only the tests you want to run.

0
source share

All Articles