user451259
user451259

Reputation: 1023

How can I make a set of tests only run as ordered tests?

I have never done ordered tests as I am of the beleif that it's not good practice. Where I work I am told to do them ,so let's cast aside what's good or bad practice.

I am new to msTests so could you help me here.

I have 10 tests and have to run in a particular order or some of them will fail.

  1. I have created a Basic test class and added all the 10 tests.
  2. I have created an Ordered test and moved to the right in the order I want to execute them.All fine.
  3. Run the tests but MsTest runs the tests twice.Once the ordered tests all successed!! But also runs the same tests in no particular order

Am I missing the obvious if I have a set of tests that are in order shouldnt those be removed as normal tests only run as ordered test.

How can I make a set of tests only run as ordered tests?

Any suggestions?

Upvotes: 6

Views: 3282

Answers (4)

John C
John C

Reputation: 1978

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

Upvotes: 0

Atulsh
Atulsh

Reputation: 31

In VSTS, whenever you create an ordered test, it actually creates a separate file for that test. So, while executing you need to execute that ordered test file only. It will include all the tests in a particular order & during execution it will run as according to it only.

Upvotes: 1

Nils Magne Lunde
Nils Magne Lunde

Reputation: 1824

I too struggled with this one, but then I found the following documentation on MSDN: Ordered Test Overview

Apparently you don't get a list of the tests in the right order in the Test View. Instead the ordered test appears as a single test.

To me this was not a very good news as my tests will be run twice when I choose to "Run All Tests In Solution" (and fail the second time when run in the wrong order), but at least I got an explanation to why it is behaving this way.

Upvotes: 2

Jason Evans
Jason Evans

Reputation: 29186

This is a popular question (though I agree, it's very bad practise). Check out this SO question:

How Does MSTEST/Visual Studio 2008 Team Test Decide Test Method Execution Order?

I've not done this myself, so cannot guarantee that any of the answers in the above question worked, but it's worth a shot.

Upvotes: 0

Related Questions