Resharper Testrunner running a class without [TestFixture] - why?

258 views Asked by At

We're using VS 2008 and Resharper 5.1 (C#) and NUnit 2.4.8.

I have this base test class which does not have a [TestFixture] attribute:

public class BaseTestCasesFixture: BaseFixture
{
    protected virtual int Calculate(DatePeriod period)
    {
        throw new NotSupportedException("Should be implemented by inheriter");
    }

    [Test]
    public void Test1()
    {
        Assert.That(Calculate(new DatePeriod(2006, 2, 28, 2007, 2, 28)), Is.EqualTo(361));
    }

And I have two descendants thereof which inherit from that base class and implement two versions of the method to be tested:

[TestFixture]
public class RealTestCaseFixture1 : BaseTestCasesFixture
{
    protected override int Calculate(DatePeriod period)
    {
        return period.DaysAsWeNeedThem;
    }

Now when I run these tests on my build server (Bamboo), everything seems to work just fine - but running them in Visual Studio with Resharper 5.1 test runner, RS insists on running my BaseTestCasesFixture (NO [TestFixture] on it!!) and miserably fails (15 times!) ....

Any idea why?? Is this a Resharper Testrunner bug? Does anyone know is that one's fixed in 6.0/6.1 ??

Update: just tested with the very latest RS 6.1 - still the same problem :-(

1

There are 1 answers

3
Pedro On BEST ANSWER

If I were to hazard a guess, the [Test] attribute on the base class is enough for Resharper to assume the [TestFixture] attribute even though it isn't present. NUnit, as of v2.5, works the same way.

Setting the base class as abstract might stop this behavior.