Skip to content

Build script execution fails over 2 netcoreapp2.0 framework tests in latest develop branch #1975

@iliashkolyar

Description

@iliashkolyar

Description

Running the build script in the latest develop branch fails over 2 precision related tests in netcoreapp2.0 framework:
Tests/FluentAssertions.Specs/Formatting/FormatterSpecs.cs

  1. When_formatting_single_it_should_have_max_precision
  2. When_formatting_double_it_should_have_max_precision

Complete minimal example reproducing the issue

  1. Clone latest code (develop branch).
  2. Run ./build.sh
  3. See failing tests:
19:01:20 [INF] > /usr/local/share/dotnet/dotnet test /Users/iliashkolyar/Development/fluentassertions/Tests/FluentAssertions.Specs/FluentAssertions.Specs.csproj --configuration Debug --collect "XPlat Code Coverage" --framework netcoreapp2.0 --no-build --results-directory /Users/iliashkolyar/Development/fluentassertions/TestResults --verbosity Minimal -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.DoesNotReturnAttribute=DoesNotReturnAttribute
19:01:21 [DBG] Test run for /Users/iliashkolyar/Development/fluentassertions/Tests/FluentAssertions.Specs/bin/Debug/netcoreapp2.0/FluentAssertions.Specs.dll (.NETCoreApp,Version=v2.0)
19:01:21 [DBG] Microsoft (R) Test Execution Command Line Tool Version 17.1.0
...


19:01:29 [ERR] [xUnit.net 00:00:05.12]     FluentAssertions.Specs.Formatting.FormatterSpecs.When_formatting_single_it_should_have_max_precision [FAIL]
19:01:29 [DBG]   Failed FluentAssertions.Specs.Formatting.FormatterSpecs.When_formatting_single_it_should_have_max_precision [1 ms]
19:01:29 [DBG]   Error Message:
19:01:29 [DBG]    Expected result to be "0.333333343F" with a length of 12, but "0.33333334F" has a length of 11, differs near "F" (index 10).

...
...

19:01:29 [ERR] [xUnit.net 00:00:05.13]     FluentAssertions.Specs.Formatting.FormatterSpecs.When_formatting_double_it_should_have_max_precision [FAIL]
19:01:29 [DBG]    at FluentAssertions.Primitives.StringEqualityValidator.ValidateAgainstLengthDifferences() in /Users/iliashkolyar/Development/fluentassertions/Src/FluentAssertions/Primitives/StringEqualityValidator.cs:line 30
19:01:29 [DBG]    at FluentAssertions.Primitives.StringValidator.Validate() in /Users/iliashkolyar/Development/fluentassertions/Src/FluentAssertions/Primitives/StringValidator.cs:line 44
19:01:29 [DBG]    at FluentAssertions.Primitives.StringAssertions`1.Be(String expected, String because, Object[] becauseArgs) in /Users/iliashkolyar/Development/fluentassertions/Src/FluentAssertions/Primitives/StringAssertions.cs:line 57
19:01:29 [DBG]    at FluentAssertions.Specs.Formatting.FormatterSpecs.When_formatting_single_it_should_have_max_precision() in /Users/iliashkolyar/Development/fluentassertions/Tests/FluentAssertions.Specs/Formatting/FormatterSpecs.cs:line 464
19:01:29 [DBG]   Failed FluentAssertions.Specs.Formatting.FormatterSpecs.When_formatting_double_it_should_have_max_precision [1 ms]
19:01:29 [DBG]   Error Message:
19:01:29 [DBG]    Expected result to be "0.33333333333333331" with a length of 19, but "0.3333333333333333" has a length of 18, differs near "3" (index 17).

Expected behavior:

Build script should pass successfully with latest code.

Actual behavior:

Build script fails.

Versions

❯ dotnet --version
6.0.200

❯ dotnet --list-sdks
2.1.202 [/usr/local/share/dotnet/sdk]
3.1.413 [/usr/local/share/dotnet/sdk]
5.0.401 [/usr/local/share/dotnet/sdk]
6.0.200 [/usr/local/share/dotnet/sdk]

❯ dotnet --list-runtimes
Microsoft.AspNetCore.App 3.1.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.19 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.10 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.0.9 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.19 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.10 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Additional Information

If I remove the #if part of both tests and use the assertion in the NETCOREAPP3_0_OR_GREATER part, both tests pass and the build script finished successfully.
Meaning result.Should().Be("0.33333334F"); and result.Should().Be("0.3333333333333333");.

I'm assuming that the netcoreapp2.0 related else in both tests was added to make those tests pass, but for some reason it doesn't on my machine.
Maybe due to the fact that i'm using a Mac (Monterey version 12.2)?

Please update if you would like me to open a PR to change the assertion or the if-else statement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions