R – Categorizing MsTest Cases

build-automationbuild-processmstestunit testingvisual-studio-2008

I'm looking for the easiest way to categorize my tests so I can run them separately.

My organization would be something like the following

  • Units Tests
  • Integrations Tests
  • Systems Test

The reasoning for this is all our testing hasn't evolved to be completely automated yet. Most of our unit tests are completely automated, while integration and system tests aren't. However all tests are still useful to invoke on developers machines.

For simplicity I'd like it if we could just commit our different types of tests with distinctive attributes [IntegrationTest] or [TestCategory("Integration")] so our build server only runs the tests we want.

I'm aware nUnit has test categories but our team likes the Microsoft Stamp of approval on MsTest + IDE integration.

How has your team solved this problem?
Are there extensions that provide this functionality?
Will this be built into .Net 4.0?

Thanks

Best Answer

Have you looked at the Test Lists feature? Click Test -> Windows -> Test List Editor to bring up the UI for managing test lists. Right click List of Tests and choose New Test List giving it a name and saving. Afterward you drag tests into the new group creating a subset of All Tests that can be run together.

Another option is to use the filter feature of the Test View tool window to select tests with similar traits. It will match partials, so you can switch to Test Name and enter something like "Asp" to match all tests containing that string and then run the results together by making a selection of all filtered items. The downside is you'd potentially have to rename your tests.

Along the same lines, and closer to what you were thinking, you could right click tests in the Test View window, choose Properties and populate the Description property or as you suggested by decorating tests with the Description attribute. Afterward you use can use the prior approach to filter tests (this time filtering on Description) albeit not the intended use of the field, it could achieve your desired result

Related Topic