TestFixture Category not being recognised as traits in VS2012 update 1

Bug #1087629 reported by Mark Heath
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
NUnit Test Adapter
Fix Released
Medium
Charlie Poole

Bug Description

The new "traits" feature in VS2012 Update 1 now allows me to run just the unit tests in a particular category which is a great improvement as we have a number of unit tests that we do not want to run automatically. However, if the [Category()] attribute is applied to the test fixture class rather than to individual tests, then VS doesn't recognise them as having a trait. This means I can't run all the tests in a particular category as the ones with categories on their test fixture are lumped together under the heading "No Traits".

Related branches

Revision history for this message
Mark Heath (mark-heath) wrote :
Revision history for this message
Charlie Poole (charlie.poole) wrote :

This is because NUnit and VS look at tests in different ways. VS only recognizes methods as tests, while NUnit treats the fixtures and other suites as tests. When you run a fixture or other suite in NUnit, it recursively runs the tests contained in that fixture or suite.

Given the different views, which one should change - NUnit or VS? It seems possible, as you suggest, to simply treat any Categories applying to a fixture as also being present on the included tests. There could be some subtle differences in looking at them this way, particularly when applying complex category expressions to the test run. However, since VS doesn't use such expressions, it's probably not an issue for the adapter. I'll look at doing it this way and run some tests.

Charlie

Changed in nunit-vs-adapter:
status: New → Triaged
Revision history for this message
Mark Heath (mark-heath) wrote :

Yes, ideally that's how I'd like to see it work, since most other tools we use do it that way (running tests in category X picks up both individual tests and testfixtures).

Thanks for your time & help on this.

Revision history for this message
Charlie Poole (charlie.poole) wrote :

To be clear, what we're talking about here is a workaround, a change in the adapter rather than NUnit itself. It should be possible to make tests run under the adapter _almost_ as they do under NUnit itself, but not exactly. That's because all the adapter can do is define the traits. The actual execution is controlled by a list of test cases that Visual Studio creates and that list won't use the same logic that is used in NUnit.

That said, if you don't use Explicit on test methods or apply categories to SetUpFixtures, it should work as you expect. We may be able to exclude explicit tests as well.

Changed in nunit-vs-adapter:
importance: Undecided → Medium
Changed in nunit-vs-adapter:
assignee: nobody → Charlie Poole (charlie.poole)
milestone: none → 0.94
Changed in nunit-vs-adapter:
status: Triaged → Fix Committed
Changed in nunit-vs-adapter:
status: Fix Committed → Fix Released
Revision history for this message
Mark Heath (mark-heath) wrote :

Only just had a chance to test this - it's working perfectly. Thanks very much.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.