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

Notification

Icon
Error

SetUp and TearDown methods not executed for NUnit tests?
henrits
#1 Posted : Saturday, February 11, 2012 2:46:00 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 2/11/2012(UTC)
Posts: 1

Hi there,

I am trying to run my NUnit tests with NCrunch. After running a test class some of the test methods fail unexectedly.
After looking into it I noticed the red dots (code NOT executed) of the lines in the SetUp and TearDown methods.

Are the methods marked with the SetUpAttribute and TearDownAttribute not execured before and after running each test?

Regards,

Henri

P.S. I am setting the Thread.CurrentThread.CurrentCulture in the SetUp method (maybe that is not allowed/respected?)
Remco
#2 Posted : Saturday, February 11, 2012 11:44:52 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 929 times
Was thanked: 1255 time(s) in 1168 post(s)
Hi Henri -

Thanks for posting! You are correct in your understanding that these methods should run.

Normally red dots indicate code that is covered by failing tests - have you customised your configuration? (not that this is a bad thing - I just want to confirm that it is actually code not covered by tests).

Something to check is whether these methods are marked as public. Normally NUnit requires this, though not all other test runners do.

Beyond the above I think the best plan of attack for an issue like this is to deductively identify what is causing the test to behave strangely. Try creating a simple test fixture with one test, a SetUpAttribute and a TearDownAttribute. Does the code marked with these attributes run as expected? If so, start slowly moving elements of your strangely behaving test into the new test that is working until you've narrowed down which change causes the test to malfunction.

As far as I'm aware, changing the current culture on the thread shouldn't cause issues with the test environment. If it does, then I definitely have something to fix :)


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