Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

attempts to run tests in class not marked with [TestFixture]
johnmwright
#1 Posted : Thursday, February 23, 2012 6:26:31 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 9/27/2011(UTC)
Posts: 45
Location: Chicago, IL

Thanks: 3 times
Was thanked: 7 time(s) in 6 post(s)
NCrunch is attempting to run tests in a class which is not marked as a test fixture.

Specifically, I have a base class which has several methods marked with [Test], as well as a setup method marked with [SetUp]

Example:
public class BaseTestClass {
[SetUp]
public void MySetup() {}

public virtual void ExtraSetupSteps() {}

[Test]
public void Test1() {}

[Test]
public void Test2() {}
}

Then, there are two other classes which extend the base class:

Example:
[TestFixture]
public class MyRealTestClass: BaseTestClass {

public override void ExtraSetupSteps() {/*stuff*/}

[Test]
public void Test3() {}

}


When running directly with TestDriven.Net, Gallio, etc, the base class is skipped over and only the extending class (marked with [TestFixture]) is attempted. However, NCrunch shows errors for the base class, implying that it attempted to execute the class directly.

Note: To resolve this issue, I simply marked the base class as abstract (which it should have been anyway) and NCrunch happy skipped over it going forward.

I'm using MbUnit v3.3 with NCrunch v1.37.0.46b in Visual Studio 2010 Ultimate
Remco
#2 Posted : Thursday, February 23, 2012 8:08:20 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,045

Thanks: 941 times
Was thanked: 1265 time(s) in 1177 post(s)
Hi John -

This isn't something that was obvious to many people (including myself at the time actually), but with the introduction of NUnit 2.5, NUnit will now run tests without a [TestFixture] attribute being present on the test class.

So what you've described is actually the intended behaviour. The fix you've implemented (make the class abstract) is also the exact right thing to do in this situation :)


Cheers,

Remco
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.030 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download