Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#377 Nunit 2.5.0.9122:setup not called when test method inherited

V2.5
open
nobody
framework (78)
5
2009-10-02
2009-10-02
Ngu Soon Hui
No

When a debugger is attached ( i.e., when I am running in Testdriven.net or NUnit GUI), I found that the Setup method wont' be called if my test method is inherited from a base method.

Here's the code, the setupCount is 0, instead of the correct result, 2.

public class SetupCallBase
{
protected int setupCount = 0;
public virtual void Init()
{
setupCount++;
}
public virtual void AssertCount()
{
}
}
[TestFixture]
public class SetupCallDerived: SetupCallBase
{
[SetUp]
public override void Init()
{
setupCount++;
base.Init();
}
[Test]
public override void AssertCount()
{
Assert.AreEqual(2, setupCount);
}
}
As far as I know NUnit 2.4 will have the above test pass.

On the other hand, the test will also pass if I don't make the AssertCount as virtual/override.

Discussion

  • Charlie Poole
    Charlie Poole
    2009-10-02

    It will be a much better guarantee that your request is not lost if you submit it as a bug as I asked on the mail list. See http://bugs.launchpad.net/nunitv2.

    (Note that the page on which you submitted this request also asked that you not
    submit bugs here.)