tags:

views:

492

answers:

1

edit: note, question 288805 is similar, however, I specifically am asking how does MSTest choose the default test order. please see the rest of this question. Thank you Eilon for the link to http://stackoverflow.com/questions/288805/.

I was looking at a legacy MSTest project. The tests were always running in the same order. The order was not alphabetic and was bouncing between methods in two *.cs TestMethod files.

I did not change the physical order of the legacy code. I did for my convenience append "MSTest01" to the method name of the first test, "MSTest02" to the method name of the second test, et cetera.

To my surprise, the execution order of the TestMethod functions changed; #3 first, #6 second, #5 third, et cetera.

When I removed the "MSTestnn" strings from the TestMethod function names, their execution order changed back to the previous ordering, i.e., one test from the first .cs file, two tests from the second .cs file, five tests from the first .cs file, et cetera.

It seems that file location may not be a factor while TestMethod function name may be a factor.

QUESTION: can anyone explain how MSTest decides on execution order of TestMethod functions?

Thank you.

Regards,
Gerry (Lowry)

A: 

Exact dup of: http://stackoverflow.com/questions/288805/how-does-mstest-visual-studio-2008-team-test-decide-test-method-execution-order

Eilon
@ Eilon: my question is not an exact duplicate of 288805 as per your suggestion; 288805 is useful if one wishes to control the order (which should only be done in rare cases); since MSTest is not random, but is consistently predictable with a priori knowledge, I was surprised that appending a sequence identifier to the TestMethod names that I was investigating affected the order in which the tests were run; this was cause for concern for me because I was attempting to annotate the tests and the system under test in order to understand legacy tests that were not sufficiently self documenting.
gerryLowry