I am writing a plugin and I am wondering on tests that generate more than one test (like Range) how to test the number of test ran for each.
[Test, Combinatorial]
public void TwoArguments_Combinatorial(
[Values(1, 2, 3)] int x,
[Values(10, 20)] int y)
{
Assert.That(x > 0 && x < 4 && y % 10 == 0);
}
this Test from Combinatorialonly make sure that the inputs are correct, but how can I make sure it ran exactly 6 tests??
You may have to expand on what you are trying to do. From the code, it appears that you want to run a test that tests the test framework!
We do that ourselves, but usually we do it through separate tests, which serve as data to the actual test. The actual test can run the (let's call it) dummy test and examine all the outputs.
For the actual test to see the the result of other tests, we need to break test independence a bit. You can generally do this but you should understand what you are doing. Remember, the method is not the test... in your case, it's six tests and none of them can see anything about the others.
You __could__ give your test class a private field, which is only used by this method, in which you count the number of times the method was called. You would have to zero that field in a OneTimeSetUp method, increment it in each call and then test it in OneTimeTearDown. However, any failure in your one time teardown would be recorded as an error (not a failure) of the entire fixture. I ran through this approach to demonstrate why a second level of test is generally better. Of course, you can do it this way, but I don't recommend.
If you want to do it in a cleaner way, create a separate assembly that contains your "dummy" tests. Make your actual test run those tests and then examine the results. You can find many examples of how to do this in the code for the actual NUnit tests.
Closing this as a question, but you can still follow up here and one of us will respond.