10

Resolved

"IUseFixture-like" for multiple classes

description

We are currently looking for a good alternative to Nunit and XUnit seems to be the one. One important feature seems to be missing which would raise XUnit to "god level" ;-).

Story: We are using Nunit not only for simple Unit-Tests but also for integration tests which are running within a similar context as the application. The components of our application are "living" in a Unity-DI-Container. The creation/bootstrapping
and disposal of that container takes quite an amount of time which increases the test duration of all our integration tests significantly which are using those components during test execution. At the moment we create this DI-Container within NUnits TestFixtureSetUp
and dispose it in the TestFixtureTearDown respectively. This ensures that all test methods within one test fixture are using the same container but still has the effect, that the unity container is created for each test fixture class.

But what we really want is something which would allow the creation of our DI container for multiple test classes and that it gets disposed after all test in those classes have been executed. I imagine something similar as the IUseFixture<> interface
but where the created data object is created only once for all the test classes implementing the same IUseFixture<DataType> interface.

Is there any such feature planned or even exists already? This would be the killer feature for moving away from Nunit!

Thanks

tschaena

comments

rbirkby wrote Sep 18, 2012 at 9:32 AM

The execution time of my integration tests is dominated by the time for fixture setup/teardown as they spin up a database per fixture and this takes around 15 seconds. It would be great to have the option of sharing the fixture across all integration tests and have XUnit manage object finalization (teardown/Dispose) for me.

BradWilson wrote Sep 19, 2012 at 1:17 PM

Our intention is to support this in xUnit.net 2.x with test collections. They are collections of test classes that have lifetime events associated with them, just like you have today with lifetime events for both test (test class ctor/dispose) and test class (fixture ctor/dispose).

BradWilson wrote Aug 18, 2013 at 5:36 PM

Fixed in 2.0 with the addition to test collections.