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

Notification

Icon
Error

NUnit Assert Not Failing Test (string comparison)
SethO
#1 Posted : Wednesday, December 2, 2015 2:40:19 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 12/19/2013(UTC)
Posts: 4
Location: United States of America

Found this issue late yesterday when comparing serialized Newtonsoft.JObjects. Can replicate with the following test:

Code:
[Test]
public void ThisTestShouldFailButDoesNot()
{
    const string expected = "{\"string\":\"e82fdc14-9fc6-4acc-86ef-95743a54b7ea\",\"bool\":true,\"int\":46}";
    const string actual = "{}";
    Assert.AreEqual(expected, actual);
}


If I debug the code, I will throw an AssertionException on the assertion line, as expected. However, the NCrunch runner reports the test as green/passing.

If any other code is placed after the "Assert.That()" line, it will not execute, and it will not have a green dot on any of the lines.

This happens on both v2.17 and v2.18.0.3.

Edit: Using NUnit v3
JoshuaPeterson
#2 Posted : Wednesday, December 2, 2015 2:44:44 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 7/15/2013(UTC)
Posts: 3
Location: United States of America

I did some further digging and got it down to this:
Code:
namespace ConsoleApplication1
{
    [TestFixture]
    public class Test
    {
        [Test]
        public void ThisTestShouldFailButDoesNot()
        {
            Assert.AreEqual("a", "{");
        }
    }
}


This should fail and throws an AssertionException, but nCrunch shows the test as passing and puts a green dot next to it.
Remco
#3 Posted : Wednesday, December 2, 2015 10:13:08 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi, thanks for sharing this issue.

This looks to be the same issue - http://forum.ncrunch.net/yaf_postst1721_NUnit-3-0-and-NCrunch-2-18---test-not-executed-during-planned-execution-run.aspx.

It's being caused by a bad string.Format on NUnit3 message logs. There'll be a fix for this in the next release. Sorry for the trouble.
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.032 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download