jeudi 30 novembre 2017

Is there any way to combine CollectionFixtures with ClassFixtures in XUnit?

I have some code that needs to get initialized once for all test classes, so I've placed this code in a CollectionFixture.

[CollectionDefinition("TestCollectionFixture")]
public class BaseTestCollection : ICollectionFixture<BaseTestFixture>
{
}

But then one of the test classes has some extra code that needs to get initialized once for all of its methods. So, I'd like to combine the CollectionFixture with an IClassFixture. So, I'd like something like the following:

[Collection("TestCollectionFixture")]
public class DummyTestClass : IClassFixture<DummyTestFixture>
{
    public DummyTestClass (BaseTestFixture baseTestFixture, DummyTestFixture dummyTestFixture)
    {
        // Do some stuff here, hopefully using both fixtures..
    }
}

Is this possible in any way?

Aucun commentaire:

Enregistrer un commentaire