sapbucket
sapbucket

Reputation: 7195

resharper test runner - how to execute by category?

Resharper version 7.1

Visual Studio 2012 Ultimate

Two part question:

Q1: When I select "run unit tests" in the solution explorer resharper automatically opens a test fixture runner and executes ALL test fixtures. However, I have categorized tests in to two categories: 1) "long running" and 2) "short running". Is there a way that after performing these steps that I can have the test runner execute "short running", only?

Q2: With the test fixture runner open, I select Group By "Categories". I see the two categories I mention above. I right click on "short running" and select "run tests". Expected is that only the "short running" tests will execute; however, BOTH the "long running" and "short running" execute. Is there a way to execute by category, and have only that category execute?

UPDATE: here is what is showing on my screen

First: R#->Options->Unit Testing (general tab)

enter image description here

Second: an example test from a random testfixture, showing usage.

enter image description here

Third: this is what I see when I execute "run unit test" from Solution Explorer, and also what I see when I right click on "short running"->"run tests" (in either case, "long running" also executes)

enter image description here

Upvotes: 1

Views: 1498

Answers (2)

citizenmatt
citizenmatt

Reputation: 18573

Are the long running tests actually running? I know it seems like a silly question, but if both long and short running tests share a test fixture, it might look like they're running, as in the screenshot you posted, but it's only the shared fixture that's run, not the actual tests. In other words, test fixtures get a node in the tree of results, and if it's shared by the tests, it can appear multiple times in the tree. At the point that the fixture runs, the test runner doesn't know what test is about to run, so marks all fixture nodes in the tree as running, although it's only the shared fixture itself that's running. It will then run the actual test, and only the tests that run are marked as running.

Upvotes: 3

Thomas Weller
Thomas Weller

Reputation: 11717

The first step is to apply category attributes to the test methods (in xUnit.Net you can use Traits with the name Category. (If you have separated your tests along Test classes/fixtures, you can apply these attributes to the classes.)

Then, based on these categories, you can make R# to only execute test methods that have one of the specified categories. You do this in the RESHARPER|Options dialog. Under Unit Testing, on the General tab, there's an input field for this.

Upvotes: 3

Related Questions