Visual Studio 2012 RC - Run Unit Tests after build - Specify test categories to run
Asked Answered
S

2

5

In VS2012 (RC, soon to be RTM) is it possible to be selective about the (nunit) unit tests that run after every build? I love this feature, but I have two test categories/assemblies - one for actual unit tests that are expected to run quickly, another for database scheme and test generation data. I do not want to run the latter after every build, though I'd like to make use of this functionality for regular unit tests. Is there any way of specifying categories/assemblies/etc. that should be executed upon a successful build? Thanks JP

Subaudition answered 2/8, 2012 at 18:54 Comment(2)
The NUnit documentation does not indicate that this functionality should be available yet. Consider filing a bug/feature request on the NUnit Test Adapter bug report site. Maybe the developers can shed light on this. Otherwise my best bet is the usage of a .runsettings file, although it is not evident how to set up this configuration.Yong
I just browsed the test adapter source code here. There are no obvious signs of handling categories in the code right now.Yong
L
4

@Gishu is correct. If you apply a filter to the Test Explorer, the runner will use the results of that filter list when choosing tests to run.

We will be continuing to add additional filter choices (e.g. Categories, Project, etc.) to the Test Explorer through and post-RTM. Stay tuned for more on this.

Laurentium answered 6/8, 2012 at 20:12 Comment(4)
I actual filed a bug/feature request for this issue earlier today (which maybe initiated this response?); anyway, there are some additional comments in the bug report.Yong
Nice to know that "Filtering on categories" is in the pipeline... +1Lothians
Thanks for the additional information. I would have split the bounty with you and @Lothians if possible, but since it is not this was the most comprehensive answer...Subaudition
@peter Looks like some additional support was added in the update today (Project + Traits), however the filter won' persist across reloads, so having Run After Build set still appears to cause your big slow integration tests to run on first build if you forget to put a filter in every time? :(Dune
L
3

On the test explorer window, there is a searchbox. You can specify filters - one that looks promising is called a TestFilePath filter. (Dropdown to see available filters)

e.g. FilePath:"Transaction" filters only the tests in the Transactions.cs file. You can use this to exclude the tests in the other assembly e.g. if the folder is Unit and Database. Specifying FilePath:"Unit" should work. Give it a try..

Docs: Search for "filtering" on the page here

Lothians answered 3/8, 2012 at 10:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.