Hi I have to use a variable in all my tests make with Nunit
SimpleContainer container = new SimpleContainer();
so I try to put this definition in the setup class:
[SetUpFixture]
public static class TestSetup
{
public static SimpleContainer container = new SimpleContainer();
}
I use static class for ability to write:
IMyClass myClassExpected = (IMyClass)TestSetup.container.GetInstance(typeof(IMyClass), null);
but after running test I get this error: "TestSetup is an abstract class"
I simply don't understand where is the problem
I would suggest you not bother with having a static instance, and instead, use inheritance.
So create a base class, which includes your object:
public class BaseTestFixture
{
public SimpleContainer Container { get { return new SimpleContainer(); } }
}
Have all your tests inherit from this:
public class GoogleTests : BaseTestFixture
{
[Test]
public void GoToGoogle()
{
Container.GetInstance(.....);
}
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments