简体   繁体   中英

NUnit Tests in generic abstract base class are ignored

I have create a generic abstract base class to do some common tests. The test are showing up, but they are ignored. Why? Example

public abstract class FooBase<TA, TB> : TestBase<TA, TB>
{
   [Test]
   public void SomeBaseTest(){}
}

[TestFixture]
public class ConcreteFooTest:FooBase<IFoo,MyContext>
{
   [Test]
   public void WorkingTest(){}
}

It this example are SomeBaseTest ignored. TestBase are used by all my tests and are only containing some help methods, and no tests

As Ritch states it is due to RS' test runner. This is a bug in RS 6.0 which is scheduled for fix in 6.1. See RSRP-273687 Unit test runner shows inconclusive with test class with generic base class .

Which test runner are you using?

And have you tried to add the TestFixture attribute?

[TestFixture]
public abstract class FooBase<TA, TB> : TestBase<TA, TB>
{
    [Test]
    public void SomeBaseTest(){}
}

The problem is likely with your test runner. Nunit 2.5.10's test runner ran it, Autotest.Net (1.3.1) ran it, and Resharper 6.0's test runner saw it, but wouldn't automatically run it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM