Nunit: Culture differences on .NET Core on non-Windows causes test failures

Created on 11 Dec 2017  ·  4Comments  ·  Source: nunit/nunit

(@nunit/framework-team We'll need to take care of this before 3.10 or else pull the .NET Standard 2.0 build.)

These tests are Windows-specific; .NET Core on other operating systems causes them to fail. Mono, however, passes the tests so it seems to produces the Windows behavior with our .NET Framework DLLs on other OSs. Our .NET Standard DLLs on .NET Core are inconsistent with our .NET Framework DLLs on Mono.

https://github.com/dotnet/corefx/issues/11221 says the date format should be up to the OS by design.
https://github.com/dotnet/corefx/issues/17052 looks like it'll have the same conclusion for the string comparisons.

  • Should we take the same stance as .NET Core and expect different results on Windows and Ubuntu?

  • Should we take the same stance as (I think) Mono does and try to polyfill the WIndows behavior onto other OSs somehow (though this seems like low ROI)?

  • We haven't yet done the work to enable PlatformAttribute on .NET Standard. Should we take the easy out for 3.10 and remove NUnit's culture APIs, or look into adding both platform-detection and culture APIs?

Failed : NUnit.Framework.Attributes.SetCultureAttributeTests.UseWithParameterizedTest()
  Expected string length 19 but was 17. Strings differ at index 6.
  Expected: "01.06.2010 00:00:00"
  But was:  "01.06.10 00:00:00"
  -----------------^

Failed : NUnit.Framework.Constraints.SubstringConstraintTests.SpecifyComparisonType(" ss ","ß",CurrentCulture,True)
  Expected: String containing "ß"
  But was:  " ss "

Failed : NUnit.Framework.Constraints.SubstringConstraintTests.SpecifyComparisonType(" ss ","ß",CurrentCultureIgnoreCase,True)
  Expected: String containing "ß"
  But was:  " ss "

Failed : NUnit.Framework.Constraints.SubstringConstraintTests.SpecifyComparisonType(" SS ","ß",CurrentCultureIgnoreCase,True)
  Expected: String containing "ß"
  But was:  " SS "

Failed : NUnit.Framework.Constraints.SubstringConstraintTests.SpecifyComparisonType(" ss ","ß",InvariantCulture,True)
  Expected: String containing "ß"
  But was:  " ss "

Failed : NUnit.Framework.Constraints.SubstringConstraintTests.SpecifyComparisonType(" ss ","ß",InvariantCultureIgnoreCase,True)
  Expected: String containing "ß"
  But was:  " ss "

Failed : NUnit.Framework.Constraints.SubstringConstraintTests.SpecifyComparisonType(" SS ","ß",InvariantCultureIgnoreCase,True)
  Expected: String containing "ß"
  But was:  " SS "
done design critical

Most helpful comment

Should we take the same stance as .NET Core and expect different results on Windows and Ubuntu?

I think this one, this isn't NUnit's problem to get in to.

All 4 comments

I'd be happy to see a .NET Core 2.0 build, even without adding new features to it that are not in 1.6. It's a reasonable piece of work to merge and then each added feature can be done one PR at a time.

Regarding the culture and string issues, I'd go with the idea that they are different on the two OS's. The tests can use a call to get the expected values for the system as opposed to using a constant.

Should we take the same stance as .NET Core and expect different results on Windows and Ubuntu?

I think this one, this isn't NUnit's problem to get in to.

Hi,
For anyone suffering from this issue, I've create a simple solution.
https://github.com/effyteva/Teva.Common.Cultures

Hello!
Maybe this solution will be useful to someone: https://github.com/dotnet/corefx/issues/11221#issuecomment-572932255

Was this page helpful?
0 / 5 - 0 ratings