Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NUnit - Loads ALL TestCaseSources even if they're not required by current test

I recently starting using NUnit to do integration testing for my project. It's a great tool, but I've found one drawback that I cannot seem to get the answer to. All my integration tests use the TestCaseSource attribute and specify a test case source name for each test. Now the problem is that preparing these test case sources takes quite some time (~1 min.) and if I'm running a single test, NUnit always loads EVERY SINGLE test case source, even if it's not a test case source for the test that I'm running.

Can this behavior be changed so that only the test case source(s) for the test I'm running load? I want to avoid creating new assemblies every time I want to create a new test (seems rather superfluous and cumbersome, not to mention, hard to maintain), since I've read that tests in different assemblies are loaded separately, but I don't know about the test case sources. It's worth mentioning that I'm using Resharper as the test runner.

TL;DR: Need to tell NUnit to only load the TestCaseSources that are needed for the tests running in the current session. Current behavior is that ALL TestCaseSources are loaded for any test that is run.

like image 637
Anshul Avatar asked Sep 05 '13 14:09

Anshul


1 Answers

Could you do this by moving your sources instantiation to a helper method and call them in the setup methods for each set of tests? I often have a set of helper methods in my integration test suite that set up shared data for different tests. I call just the helper methods that I need for the current suite in the [Setup]

like image 165
Jim Sowers Avatar answered Sep 21 '22 07:09

Jim Sowers