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

Notification

Icon
Error

ExpectedException Attribute hides failures in TestCleanup
majaco
#1 Posted : Monday, January 30, 2017 9:32:59 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/30/2017(UTC)
Posts: 1
Location: United States of America

I created a unit test that passed NCrunch locally but then failed during a gated build on the TFS build server. It appears NCrunch runs TestCleanup code differently from how it is processed by MSTest when the test is decorated with the ExpectedException attribute.

This test class demonstrates the problem, where exceptions that occur during TestCleanup are ignored by unit tests decorated with the ExpectedException attribute:
Code:

    [TestClass]
    public class TheTestClass
    {
        [TestCleanup]
        public void ExceptionsOccurringDuringCleanupAreIgnoredOnTestsMarkedWithExpectedExceptionAttribute()
        {
            Assert.Fail();
        }

        [ExpectedException(typeof(Exception))]
        [TestMethod]
        public void ThisTestPassesWithNCrunch()
        {
            throw new Exception();
        }

        [TestMethod]
        public void ThisTestFailsWithNCrunch(){ }
    }

Is this an NCrunch bug? If so, will it be corrected?

Remco
#2 Posted : Monday, January 30, 2017 10:13:04 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, thanks for sharing this problem.

This looks to be a compatibility hole. I'll see what I can do to get it fixed. Thanks again for bringing it to my attention!
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.040 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download