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

Notification

Icon
Error

MbUnit SetUp method not being run when it is an override and base also marked SetUp
canuckotter
#1 Posted : Wednesday, June 27, 2012 1:55:05 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/27/2012(UTC)
Posts: 3
Location: Ottawa

I've got a bunch of MbUnit-based tests that run fine when run through R#, but when I try to run them through NCrunch a bunch of them are failing. The test classes are all subclasses of an abstract base class (which is indeed marked as abstract). In the base class, there is a virtual Setup() method defined (which is marked with [SetUp]) and then the actual test classes override Setup and also mark their overrides with the SetUp attribute. None of the code in the subclasses' overrides are getting called during the setup phase. If I change the method definition in a subclass to use new instead of override, the Setup method is discovered properly and runs just fine.

I've also tried a slightly different scenario, where the virtual method in the base class is NOT marked with [SetUp]. In that case, the SetUp method in the child class (the one with actual tests) is discovered and used properly. Also, if I change the name of the method in the child class so it's not an override of anything, it's discovered properly.

I realise this is kind of a weird setup, but it works in the standard test runners, just not in NCrunch. Could NCrunch's test runner be updated to be consistent with the way other test runners work in that regard?
Remco
#2 Posted : Thursday, June 28, 2012 9:24:13 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
Hi, thanks for posting!

The test discovery for MbUnit is delegated very much to MbUnit/Gallio underneath the hood of NCrunch. NCrunch does, however, have some not-so-subtle differences in how it manages the environment around the test runner.

Can you tell me what you have set for the 'Framework utilisation type for Gallio/Xunit' underneath your NCrunch solution configuration? Do the tests start working correctly if you change this setting?


Cheers,

Remco
canuckotter
#3 Posted : Friday, June 29, 2012 12:43:46 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/27/2012(UTC)
Posts: 3
Location: Ottawa

Remco;2297 wrote:
Can you tell me what you have set for the 'Framework utilisation type for Gallio/Xunit' underneath your NCrunch solution configuration? Do the tests start working correctly if you change this setting?


It was set to UseStaticAnalysis. I switched it to UseDynamicAnalysis and it had the same problem. I can't get it to load in Icarus to test directly, because somewhere along the way an exception is thrown (looks like it might be a 32/64bit mismatch, maybe? Although everything else is OK with it...) but I don't see the same behaviour when running the unit tests in Visual Studio through Resharper + Gallio...

Anything else I could look at? Or should I be going and asking the Gallio folks?
Remco
#4 Posted : Monday, July 2, 2012 3:50:56 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
Thanks. Can you tell me which version of the Gallio adapter you are using with your Resharper integration? Also, is the abstract base class sitting inside the same project/assembly as the derived test? (If not, does it make any difference if you change this?).
canuckotter
#5 Posted : Tuesday, July 3, 2012 12:53:22 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/27/2012(UTC)
Posts: 3
Location: Ottawa

I've got Gallio 3.2.3 installed. The base class is actually in a separate assembly, to which my test assembly has a binary reference (not a project reference - they're different solutions). I'll try to find time tonight to test what happens if I move the base class into the same assembly. (I can't do it with my real project without creating a circular reference or changing several dozen files.)
Remco
#6 Posted : Wednesday, July 4, 2012 12:06:29 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 964 times
Was thanked: 1296 time(s) in 1202 post(s)
Thanks. I have a feeling that this issue may be related to cross-assembly resolution during test discovery (which is something that NCrunch does handle slightly differently to other test runners). It would be great to hear if moving the base class makes any difference for you.
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.041 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download