Skip to content

Flaky test: UnitsNet.Tests.UnitSystemTests.PositiveInfinityFormatting #436

@angularsen

Description

@angularsen

This only happens very rarely on AppVeyor (first time I can think of), but @gojanpaolo reports it happens all the time on his setup. I assume this is due to manipulating static values in other tests, such as:

GetDefaultAbbreviationFallsBackToUsEnglishCulture()
{
    var zuluCulture = new CultureInfo("zu-ZA");
    CultureInfo.CurrentCulture = CultureInfo.CurrentUICulture = zuluCulture;

https://ci.appveyor.com/project/angularsen/unitsnet/build/724/tests

UnitsNet.Tests.UnitSystemTests.PositiveInfinityFormatting

Assert.Equal() Failure
          ↓ (pos 0)
Expected: ∞ m
Actual:   Infinity m
          ↑ (pos 0)

The following:

Console.WriteLine(double.PositiveInfinity.ToString(CultureInfo.InvariantCulture));
Console.WriteLine(double.PositiveInfinity.ToString(new CultureInfo("zu-ZA")));

/* Prints:
Infinity
∞
*/

So the fix is likely one or both of:

  1. Ensure tests that rely on manipulating CultureInfo or other static values are NOT run in parallel (can xunit selectively configure this?)
  2. Set CultureInfo properties back to their original values so it doesn't pollute other tests in same test class (I think all tests in one class are run in the same app domain and share static values)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions