Reputation: 126982
I've recently split our nebulously-defined unit testing project into two projects, one for unit testing and one for (what the bulk of our tests are) integration tests. This is with the hope of not-so-subtly prodding our dev team (myself included) to write better tests and code that is more easily tested. (And, by extension, more easily unit tested.)
In doing so, I've found using MSTest within Visual Studio to actually be kind of frustrating, as it is slow but more importantly it wants to run all tests in a given solution rather than all tests in a given project. I've crossed this first hurdle, as I eventually came across the Test List Editor, which allows you to create lists and then assign your tests to the list. I created a list for unit tests, checked all of the tests from the unit test project and dragged them over, and did the same for the integration tests. You can run each list independently of any others.
This gets us to the heart of the matter: Is it possible to simply have these lists grow on their own? IE., can I tie an entire project to a list, or at the very least have the lists update themselves? I want to make it as easy as possible on our developers (myself included) to keep these lists up to date and, most importantly, to actually run the tests.
Upvotes: 4
Views: 305
Reputation: 2174
In Test View (Test->Windows -> Test View) and Test Results (Test -> Windows -> Test Results) you can group the tests by a number of different criteria, one of which is Project. In Test View you can then select a project and click on the 'run selection' button.
Edit:
Note that if you want new tests to automatically update in the test view, you need to uncheck the "disable background discovery of test methods" option in "Tools -> Options -> Test Tools -> Test Project" (restart VS after making this change). If this option is checked, you need to click refresh before any new tests are added.
Edit 2
Some more info: You can assign a keyboard shortcut to "Run selection", (e.g. Ctrl R, S) so you can run all tests for the project that is currently selected in the test view even if the test view window doesn't have focus (It needs to be open somewhere though). So in Test View you can select the project you are currently working in, Open up a test class in that project, add a test, and immediately press your keyboard shortcut, and all tests in the project, including the new one, will be run.
Upvotes: 2