Q:

Resolving NUnit "No suitable constructor was found" message

I have a unit test class:
[TestFixture]
public class SomeClassIntegrationTests : SomeClass

With public constructor:
public SomeClassIntegrationTests (ILogger l) : base(l)
{
}

When I attempt to run the test I get "No suitable constructor was found" error.
I tried changing the TestFixture attribute to [TestFixture(typeof(ILogger))] but it results in the same error message not allowing me to run or debug the test.
Any idea how to modify the TestFixture attribute to get the test to run or resolve this issue in some other way?

A:

You probable need an instance of a class implementing ILogger.
Option 1: use null (if the logger is not really required):
[TestFixture(null)]

Option 2: use always the same concrete class (or a mock): add a parameterless constructor
SomeClassIntegrationTests()
: this(new MyLogger())
{
}

and
[TestFixture]

Option 3: you may want to test with different loggers
SomeClassIntegrationTests(Type t)
: this((Ilogger)Activator.CreateInstance(t))
{
}

and
[TestFixture(typeof(MyLogger))]

