I want to share DBfixture in all tests. This is the collection created for this purpose:
[CollectionDefinition("db")]
public class TestColDefinition : IClassFixture<DBfixture> { }
I have a base class from which i derive my test classes:
public class TestBase
{
protected readonly ITestOutputHelper testOutputHelper;
protected DBfixture dbf;
public TestBase(ITestOutputHelper testOutputHelper, DBfixture dbf)
{
this.testOutputHelper = testOutputHelper;
this.dbf = dbf;
}
}
[Collection("db")]
public class TestClass1 : TestBase
{
public TestClass1(ITestOutputHelper testOutputHelper, DBfixture dbf) : base(testOutputHelper, dbf) { }
[Fact]
public void fact(){}
}
[Collection("db")]
public class TestClass2 : TestBase
{
public TestClass2(ITestOutputHelper testOutputHelper, DBfixture dbf) : base(testOutputHelper, dbf) { }
[Fact]
public void fact(){}
}
But when I run tests two DBfixture objects are created (one for each test class). Without collection four objects are created. How do I setup this so that one object is shared among all test classes?