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

Notification

Icon
Error

TestFixtureSetUp not running for nested class, bug?
WinMan
#1 Posted : Tuesday, November 27, 2012 11:46:29 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 11/27/2012(UTC)
Posts: 5
Location: Sweden

We have this setup:
Code:

[TestFixture]
public class ATest
{

	[TestFixtureSetUp]
	public void ParentFixtureSetup()
        {
		// Some setup	
	}

        [TestFixture]
        public class NestedClass
        {
		[Test]
		public void SomeTest()
		{
			//Fails since the setup in  ParentFixtureSetup did not run
		}
   
	}
}


This runs ok in NUnit test runner. Is this a bug?
Remco
#2 Posted : Tuesday, November 27, 2012 8:19:00 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi, thanks for posting!

All actions in NCrunch revolve around the tests themselves, where fixtures are merely containers of tests. It isn't logically possible for an empty fixture to represented in NCrunch, and as such it will be ignored by NCrunch during test discovery. Every fixture in NCrunch must have at least one test to be detected. As not all frameworks behave like this (i.e. later versions of NUnit), you could probably consider it a bug - but it's so deeply tied in to the way that NCrunch works that I don't expect this to ever change in future.

I'm not completely sure as to the way your test is structured, but I'm wondering if you're using static state of some kind that is shared between the ParentFixtureSetup() and the nested test. I recommend against this kind of test arrangement as it is actually sequence-dependent execution of two completely different tests - even under NUnit, the ATest fixture can be executed separately from the NestedClass fixture and vice versa.


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.031 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download