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

Notification

Icon
Error

ClassInitializeAttribute from Base Class isn't executed (MSTest)
MatthewSteeples
#1 Posted : Friday, September 8, 2023 8:11:20 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 10/28/2014(UTC)
Posts: 130
Location: United Kingdom

Thanks: 7 times
Was thanked: 18 time(s) in 16 post(s)
See https://github.com/matthewsteeples/testattributes for a repro

If you run the DerivedTestMethod1 test, the following methods _should_ be executed

* ClassInit.AssemblyInitialize
* ClassInit.ClassInitMethod
* DerivedClassInit.ClassInitMethod2
* DerivedClassInit.DerivedTestMethod1

The 2nd bullet point does not get executed by NCrunch, but does by MSTest
Remco
#2 Posted : Saturday, September 9, 2023 12:07:35 AM(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 sharing this.

Yes, we have no handling for InheritanceBehavior.BeforeEachDerivedClass. I'll take a look and see if we can find a way to introduce it.
MatthewSteeples
#3 Posted : Wednesday, September 27, 2023 8:21:13 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 10/28/2014(UTC)
Posts: 130
Location: United Kingdom

Thanks: 7 times
Was thanked: 18 time(s) in 16 post(s)
Hi Remco,

Just wondering if you'd had chance to have a look at this yet? Not necessarily the InstanceBehaviour attribute but the ability for multiple ClassInit methods to be called.
Remco
#4 Posted : Wednesday, September 27, 2023 11:34:35 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)
Sorry, we've pretty snowed under with V5 work at the moment. I hope to get to this issue later in the year. I'd recommend adapting your code with a workaround for the time being, I don't think I'll be able to provide a fix for this in the short term.
MatthewSteeples
#5 Posted : Sunday, October 1, 2023 11:15:07 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 10/28/2014(UTC)
Posts: 130
Location: United Kingdom

Thanks: 7 times
Was thanked: 18 time(s) in 16 post(s)
No problem. We'll find a workaround
1 user thanked MatthewSteeples for this useful post.
Remco on 10/2/2023(UTC)
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.034 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download