SeanKilleen
SeanKilleen

Reputation: 8977

NUnit: Can I use an empty TestCaseSource and still have a test pass?

I currently have some unit tests running against all of our controllers and actions, and an additional test for some "temporary exemptions" that we allow (but that receive other checks as a result).

We were able to remove all of our temporary exemptions (a good thing), but the functionality needs to remain in place for future use.

However, since the TestCaseSource is now empty, NUnit fails the test with "no arguments were provided".

I don't necessarily disagree with the behavior, but given my situation, is there any way to ignore the test only when the TestCaseSource is empty, rather than failing with this message?

Upvotes: 1

Views: 291

Answers (1)

Charlie
Charlie

Reputation: 13736

There is no way to ensure that the functionality remains in place unless you have a test for it. So it's best to keep at least one test.

I can't give you details, since I don't know how your exemptions work, but I'd try to create a fake exemption that uses whatever underlying "exemption functionality" you have implemented. The fake class/classses needed to implement this should be a part of your tests, not of your SUT.

OTOH, if you prefer not to run the tests, just comment out the TestCaseSource attribute and remember to uncomment it when you are adding exemptions.

Upvotes: 0

Related Questions