Is there any way to tell ReSharper to execute a certain group of tests in a project before others? I still want the parallel execution and I don't need to control it per-method, just per-class will do. The test framework is MSTest if that makes a difference.
The reason I want to do this is that some tests work at a low level and are very fast, but other tests work at higher levels and are much slower. I want the fast tests to run first, because if they fail then I know there's something wrong and there's no point in continuing. However, ReSharper currently runs my slow tests first.
Edit: The tests are not run in alphabetical order for me (R# 7.1 on VS 2010). I have one source file per class. The tests within a class seem to be run in the order the methods appear in the source code, but I cannot figure out how R# determines the order of test classes. That's what I'm after, since slow and fast tests are in separate classes. That's not alphabetical either, but it is consistent from run to run.
Edit 2: OK, figured it out (see answer).
This seems like a bit of a hack, but I found that if I remove the files with the slow tests from the project and re-add them they then get run last. So it appears that R# keeps track of the order in which source files containing test classes were added and runs them in that order. (Editing the .csproj file to re-order the files had no effect, so it doesn't seem to use that.)
The reason I want to do this is that some tests work at a low level and are very fast, but other tests work at higher levels and are much slower.
I would suggest a couple of methods:
Split the tests into two separate projects. Put the "fast" tests into
YourProject.Test.Unit
and the slow tests in
YourProject.Test.Integration
Integration tests are normally tests which interact with other components (e.g.. a network, database, file system, etc) which could lead to slower test runs. It could be that your slower tests are accessing an external resource (we don't know that).
Or use @thersch's suggestion of using categories to mark out the slower tests. I would use the category method is your tests really are all unit tests, and thus it would not make sense to split them.
It seems that test execution is in alphabetical order in form of .... So you could change your namespace/class names to match the test order. But I guess that is not an option for you.
Another option is to add tests to different test sessions in "Unit Test Sessions" window. Move fast tests to Session #1 and slow tests to session #2. Then you run only the one test session you need.
Not an option is to add TestCategory to your test methods (i.e.: [TestCategory("Fast"), TestMethod]
and [TestCategory("Slow"), TestMethod]
) and group your tests in Unit Test Sessions window by Categories. This has no effect to test order.
Or, you could create a Test which orchestrates calls to other tests in the order that you want - So this test itself acts as a "session".
[TestMethod]
public void A_RunAllTests()
{
Test1();
Test2();
.
.
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With