This is driving me crazy! I am using NUnit version 3.6.0 and I am getting unexpected results from my tests. I have created a really simple test to demonstrate the problem I have:
[TestFixture]
public class NunitTest
{
[Test]
public void TestIt()
{
string x = "x";
string y = "y";
// this fails (expected) but with NullReferenceException (unexpected)
Assert.That(x, Is.EqualTo(y));
}
}
When the test runs I get a NullReferenceException when I am expecting something like "expected is 'X', actual is 'Y'"
I have furthered the asserts and they all pass
[TestFixture]
public class NunitTest
{
[Test]
public void TestIt()
{
string x = "x";
string y = "y";
// this passes
bool atest = x.Equals(y);
Assert.IsFalse(atest);
// this passes
Assert.IsNotNull(x);
// this passes
Assert.IsNotNull(y);
// this fails (expected) but with NullReferenceException (unexpected)
Assert.That(x, Is.EqualTo(y));
}
}
The other weird thing is that when the values are equal the test passed correctly. Also worth noting I get exactly the same problem when I use Assert.AreEqual(x, y)
Stack Trace:
at NUnit.Framework.Assert.ReportFailure(String message)
at NUnit.Framework.Assert.ReportFailure(ConstraintResult result, String message, Object[] args)
at NUnit.Framework.Assert.That[TActual](TActual actual, IResolveConstraint expression, String message, Object[] args)
at NUnit.Framework.Assert.That[TActual](TActual actual, IResolveConstraint expression)
at VSI.Tests.NunitTest.TestIt() in c:\Users\DavidBecker\Documents\Visual Studio 2013\Projects\VSI.Tests\VSI.Tests\NunitTest.cs:line 30
Tools:
.NET Framework version 4.5.1
Visual Studio 2013 Professional
Resharper Version 9
EDIT: I am running the tests from Resharper.