Skip to content

DefaultFloatingPointTolerance ignored for TestCaseData #4750

@MartinM85

Description

@MartinM85

I'm trying to upgrade from v3 to the latest v4, but I'm facing an issue with TestCaseData and DefaultFloatingPointTolerance.
I've a test

[TestCaseSource(nameof(MyDataSet))]
[DefaultFloatingPointTolerance(1E-6)]
public (double, bool) DeadTimeCorrection(double parameter1, int parameter2)
{
    return MyClass.Calculation(parameter1, parameter2);
}

public static TestCaseData[] MyDataSet = 
{
    new TestCaseData(367879441.1714423d, 1).Returns((980833173.431083d, false))
};

In v3, everything works fine, but with NUnit 4.1.0 the test is failing

Message: 
Assert.That(result, Is.EqualTo(_testMethod.ExpectedResult))
Expected: (980833173.43108296d, False)
But was: (980833173.43108344d, False)

Stack Trace: 
TestMethodCommand.Execute(TestExecutionContext context)
<>c__DisplayClass1_0.b__0()
DelegatingTestCommand.RunTestMethodInThreadAbortSafeZone(TestExecutionContext context, Action action)

  1. at NUnit.Framework.Internal.Commands.TestMethodCommand.Execute(TestExecutionContext context)
    <>c__DisplayClass1_0.b__0()
    DelegatingTestCommand.RunTestMethodInThreadAbortSafeZone(TestExecutionContext context, Action action)
    BeforeAndAfterTestCommand.Execute(TestExecutionContext context)
    BeforeTestCommand.Execute(TestExecutionContext context)
    <>c__DisplayClass3_0.b__0()
    <>c__DisplayClass1_0`1.b__0(Object _)

Obviously, DefaultFloatingPointTolerance is ignored

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions