0

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 :-(

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

2

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.

Pedro
  • 12,032
  • 4
  • 32
  • 45
  • Yep, that's exactly the response I got from the ReSharper team when I filed a bug for this behavior -- it's working as designed. NUnit will run that test fixture, so ReSharper does too. And yes, I can confirm that making it abstract will tell ReSharper not to run it. – Joe White Jan 10 '12 at 20:14
  • Yes, thanks - that does seem to do it! I still think it's a bug by RS to "execute" a class which has **not** been marked with a `[TestFixture]` attribute - filed a bug report with JetBrains and we'll see if anything gets done in this matter. – marc_s Jan 10 '12 at 20:43
  • @JoeWhite: strange - because in my case, on the **build server**, NUnit does **NOT** run that class since it's not marked with [TestFixture] ..... – marc_s Jan 10 '12 at 20:44