Assign multiple test categories using TestCategoryAttribute

I am using TestCategoryAttribute to filter which tests to run during builds and wandered, how to -how to assign multiple test categories.
According to constructor documentation only single category can be specified.  However TestCategories Property (plural!)can return multiple categories.
Grouping Tests into Test Categories: You can add an automated test to one or multiple test categories using a test attribute. Each test can belong to multiple test categories.
The recommended approach from MSDN How to: Group and Run Automated Tests Using Test Categories is to specify multiple TestCategory attributes like the following
[TestCategory("Nightly"), TestCategory("Weekly"), TestCategory("ShoppingCart"), TestMethod()]
public Void DebitTest() { }
shows how enums can be used instead of strings.
It also explains, that TestCategories Property can be used in derived custom attributes.
Advertisements