简体   繁体   中英

Run/Group Tests by Category Attribute of NUnit in Visual Studio

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?

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 ,

在 Visual Studio 中分组单元测试

or there is a grouping dropdown in the upper left corner of the Test Explorer window.

在 Visual Studio 中分组单元测试

Visual Studio groups tests by Class, Duration, Outcome, Traits or by Project. Traits map to NUnit's Categories.

We can create Playlist and organize the tests by group. Open Test Explorer, right click any test/or group of tests, add to Playlist, and save the Playlist to a file. then we can open one Playlist file and click to run it as a group.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM