William
William

Reputation: 443

How can I split same-project unit tests into separate assemblies?

I have a few test projects, one of which has many unit tests, all very related to doing certain calculations. Running all unit tests takes a long time. So, I'm looking for a way to easily split tests into nightly unit tests and all other unit tests. How can I conveniently specify which test fixtures and test methods should be nightly? In other words, is there a way to split tests from within the same project into separate assemblies?

What I've thought of and tried so far:

I would love to be able to use a class attribute to specify which tests will run nightly, e.g.:

[TestClass, Nightly]
public class MyTestClass { }

Any ideas?

Upvotes: 0

Views: 521

Answers (1)

Alexei Levenkov
Alexei Levenkov

Reputation: 100527

You can have as many unit test projects for the same solution as you need.

If you want to go with separate project (i.e. your build system only setup to run test from separate project) I'd have new project sharing tests from old one - create new project and add files from old one as "link" (there is small option on "Open" button of add file dialog to do so).

Alternatively you can add attributes to tests (i.e. TestCategoryAttribute) and make your test runner respect those.

Upvotes: 1

Related Questions