Exclude tests from a certain category
Asked Answered
N

1

14

"Bottom" line: How do you set up NCrunch to exclude all tests in a certain category, e.g. "LongRunning"?


Stack Overflow search provided zero results, and the relevant NCrunch wiki page merely informs me that "NUnit's Category attribute is just as powerful as NCrunch", which is nice but doesn't tell me how to use those categories.

To further clarify, I was expecting a checkbox-list somewhere to turn categories on/off, similar to the /exclude option in the NUnit Test Runner to exclude all tests in certain categories.

PS. I've tagged the question only with NCrunch, it didn't seem relevant that I'm using NUnit as my testing framework. Should the answers indicate otherwise I'm happy to add the tag.

Nearby answered 25/9, 2012 at 9:47 Comment(0)
N
18

After some more searching on the wiki I found this page describing it: you need to create a new Engine Mode. Who would've thought?

Here's the two relevant steps/screenshots that got this working for me. First, go to the NCrunch menu, choose "Set Engine Mode" and then "Customise Engine Modes...":

Step 1 - enabling custom engine

And then step 2, choose "Run all tests automatically + CATEGORY FILTER", click "Add Engine Mode". Then give it a name, and add a condition "does not have category" and choose your category to ignore, e.g. "LongRunning". Then hit "OK":

Step 2 - add custom engine with filter on "not in category"

Finally choose the new engine and your tests are filtered!

Nearby answered 25/9, 2012 at 19:59 Comment(3)
This is what I'm currently doing, but it still doesn't perfectly meet my needs. In addition to my unit tests, I have integration tests that hit the database. When I'm out of office without a network connection, I want those tests completely ignored, rather than just not having them run automatically. I don't think there's currently a way to achieve this, but hopefully a future version allows it :(Caulicle
I agree @Caulicle Upon initial load NCrunch always runs all tests apparently even with DoesNotHaveCategory set. Those tests are then marked as broken.Castoff
Just saw a post on the NCrunch forums, this actually does work correctly. The tests show as broken because of cached data. Close your solution and delete the _NCrunch_SOLUTION directory. Those tests will not be run and won't display as broken anymore.Castoff

© 2022 - 2024 — McMap. All rights reserved.