TL;DR - I\'m looking for xUnit\'s equivalent of MSTest\'s AssemblyInitialize (aka the ONE feature it has that I like).
Specifically I\'m looking for it
I use AssemblyFixture (NuGet).
What it does is it provides an IAssemblyFixture interface that is replacing any IClassFixture where you want the object's lifetime to be as the testing assembly.
Example:
public class Singleton { }
public class TestClass1 : IAssemblyFixture
{
readonly Singletone _Singletone;
public TestClass1(Singleton singleton)
{
_Singleton = singleton;
}
[Fact]
public void Test1()
{
//use singleton
}
}
public class TestClass2 : IAssemblyFixture
{
readonly Singletone _Singletone;
public TestClass2(Singleton singleton)
{
//same singleton instance of TestClass1
_Singleton = singleton;
}
[Fact]
public void Test2()
{
//use singleton
}
}