I am trying to use the Category Attribute of NUnit with my Visual Studio Profession 2015. However, the attribute doesn't seem to be categorizing the Tests in the Test Explorer.
[Test]
[Category("ValidLogins")]
I tried this as:
[Test, Category("Login")]
But even that didn't work. Any suggestion?
The Category attribute provides an alternative to suites for dealing with groups of tests. Either individual test cases or fixtures may be identified as belonging to a particular category. Some runners, including the Console Runner, allow specifying categories to be included in or excluded from the run.
If you add a second parameter with the Values attribute, for per value of the first parameter, NUnit will add a test for every value of the second parameter. Another way to avoid having to write duplicate tests when testing the same behaviour with different inputs is to use TestCase attribute on the test itself.
Effectively, using TestCategory lets you create a group of tests using any arbitrary system you want. This allows you to create (and run!) groups of tests that you feel are related without having to run every test in a class, a project or a solution.
By default, Visual Studio's Test Explorer Window groups tests by Outcome which groups by Passed, Failed and Not Run. Many people miss the options for changing the grouping.
You can right-click on a group and select Group By,
or there is a grouping dropdown in the upper left corner of the Test Explorer window.
Visual Studio groups tests by Class, Duration, Outcome, Traits or by Project. Traits map to NUnit's Categories.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With