I wanted to unit-test an abstract class by creating abstract test-class with abstract factory method (using this approach) that polymorphically gets the concrete instance. Something like this:
public abstract class Base
{
public bool MyMethod()
{
return true;
}
}
public class Derived : Base {}
// Tests
public abstract class BaseTest
{
[Fact]
public void MyMethod_MakeTestFailByAssertingFalseReturn()
{
//Arrange
var instance = GetConcreteInstance();
//Act
bool result = instance.MyMethod();
//Assert
Assert.False(result);
}
protected abstract Base GetConcreteInstance();
}
public class DerivedTest : BaseTest
{
protected override Base GetConcreteInstance()
{
return new Derived();
}
}
So far, so good. But ReSharper test runner gives this error:
Inconclusive: Test wasn't run
for all tests inside BaseTest class. Even the ones that are ignored. I tried to run the tests with Visual Studio test runner, but it doesn't detect any of them.