How to deal with long-running tests in MSTest
I've got a few tests using the MSTest framework which are very long running. These tests are valuable, and I sometimes run them manually. But when I simply want to run "all tests" I want to exclude them by default. I'm using the Resharper test runner to run tests.
When I mark test test as [Ignored]
then I can't run it anymore, not even when directly selected.
How can I approach this in a good way?
I don't know any built-in way how to accomplish that with MSTest. But I see some alternatives:
- Use a dedicated MSTest project (e. g.
LongRunningTests
) → you can run these tests manually on demand, on your CI environment, etc. - Switch over to NUnit and use the
Explicit
attribute. - Create your own
LongRunningTest
attribute within MSTest and exclude this category within the UI. - Create another build configuration (e. g.
Release
,Debug
andLoadTest
) and work with preprocessor directives:
#if !LoadTest
[Ignored]
#endif
[TestMethod]
public void TestSomething()
{
// the usual AAA stuff
}