nunit-core team mailing list archive
-
nunit-core team
-
Mailing list archive
-
Message #00861
[Bug 532488] Re: constraints from ConstraintExpression/ConstraintBuilder are not reusable
** Branch linked: lp:nunit-3.0
--
constraints from ConstraintExpression/ConstraintBuilder are not reusable
https://bugs.launchpad.net/bugs/532488
You received this bug notification because you are a member of NUnit
Developers, which is subscribed to NUnit V2.
Status in NUnit Test Framework: Fix Committed
Status in NUnit V2 Test Framework: Fix Released
Bug description:
Constraint that I receive from syntax helper (Is.Not.Null) is not reusable, but I guess this is more general problem.
I found this problem when upgrading nunit.framework.dll from v2.4.6 to v.2.5.3. In both cases tests were executed witn NUnit 2.5.3 console.
Worst thing about this problem seems that tests could actually pass when they should fail if you reuse constraint.
Here is simple example that demonstrates the problem:
using NUnit.Framework;
using NUnit.Framework.Constraints;
namespace NUnit_2_5_3_bug
{
[TestFixture]
public class FailToReuseConstraint
{
/// <summary>
/// Constraint from <see cref="ConstraintExpression"/>.
/// </summary>
/// <remarks>
/// Demonstrates that constraint received from syntax helper is not reusable.
/// </remarks>
[Test]
public void FromSyntaxHelper()
{
Constraint expression = Is.Not.Null;
Assert.That(this, expression, "one");
Assert.That(this, expression, "two"); // this step fails on NUnit.2.5.3
}
/// <summary>
/// How NUnit 2.4 did it (i think).
/// </summary>
[Test]
public void NotConstraint()
{
Constraint expression = new NotConstraint(Is.Null);
Assert.That(this, expression, "one");
Assert.That(this, expression, "two");
}
}
}
References