Prevent NUnit from building tests in any other class besides the one we’re currently running a test in? (AKA run tests in parallel?)

I've got an odd question for which Google has proven barren:

I've got a project in .net with ~20 classes that all have tests in them. One of the classes has common test setup code, although a few of the classes have their own TestFixtureSetup that looks exactly like the common class (not my architecture choice – this predates my employment). I have my own test class for which I have some different code that runs prior to running a few particular tests within the class.

Some more info that's relevant: The custom setup code that I have enables data to be available for a few combinatorial tests I have in my own test class. As the value source for the combinatorial params, the List that is returned first initializes some data.

Alright, here's the question: When I try to run a test in ANOTHER test class, it's "building" the tests from every other class. In my case, it's building the combinatorial test that I have – and thus, triggering the custom setup method that I have.

How do I prevent NUnit from building tests in other classes? As in, I run a test in one class, all I'd like NUnit to do is build tests from that class ONLY.

I tried to remove any NDA-no-no language, but here's the combinatorial I have:

[Test, Combinatorial, Category("Regressive")] public void Test05_CombiTestExample( [ValueSource("ListA")] User user, [ValueSource("ListB")] KeyValuePair<string, string> searchKvp, [ValueSource("ListC")] string scope) { And here's one of the lists that is being reference:

public IEnumerable<KeyValuePair<string, string>> ListB { get { InitCustomData(); if ([Redacted] != null) { return new Dictionary<string, string>() { [Redacted] }; } return null; } } The line in question is "InitCustomData();" which, because my combinatorial is being built prior to running any setup or anything, is being executed anyway. I want this to stay here – I just don't want NUnit to start building test cases from any other class besides the one it's currently running a test in.

by ProfWhite via /r/csharp

Leave a Reply