Nunit: 非 Windows 上 .NET Core 的文化差异导致测试失败

创建于 2017-12-11  ·  4评论  ·  资料来源: nunit/nunit

(@nunit/framework-team 我们需要在 3.10 之前解决这个问题,否则拉取 .NET Standard 2.0 版本。)

这些测试是特定于 Windows 的; 其他操作系统上的 .NET Core 会导致它们失败。 然而,Mono 通过了测试,因此它似乎在其他操作系统上使用我们的 .NET Framework DLL 产生了 Windows 行为。 我们在 .NET Core 上的 .NET Standard DLL 与我们在 Mono 上的 .NET Framework DLL 不一致。

https://github.com/dotnet/corefx/issues/11221说日期格式应该由设计的操作系统决定。
https://github.com/dotnet/corefx/issues/17052看起来对于字符串比较会有相同的结论。

  • 我们是否应该采取与 .NET Core 相同的立场并期望在 Windows 和 Ubuntu 上得到不同的结果?

  • 我们是否应该采取与(我认为)Mono 相同的立场,并尝试以某种方式将 WINdows 行为填充到其他操作系统上(尽管这似乎是低投资回报率)?

  • 我们尚未完成在 .NET Standard 上启用PlatformAttribute的工作。 我们应该在 3.10 中轻松删除 NUnit 的文化 API,还是考虑添加平台检测和文化 API?

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

最有用的评论

我们是否应该采取与 .NET Core 相同的立场并期望在 Windows 和 Ubuntu 上得到不同的结果?

我认为这个,这不是 NUnit 的问题。

所有4条评论

我很高兴看到 .NET Core 2.0 构建,即使没有向它添加 1.6 中没有的新功能。 合并是一项合理的工作,然后每个添加的功能可以一次完成一个 PR。

关于文化和字符串问题,我认为它们在两个操作系统上是不同的。 测试可以使用调用来获取系统的预期值,而不是使用常量。

我们是否应该采取与 .NET Core 相同的立场并期望在 Windows 和 Ubuntu 上得到不同的结果?

我认为这个,这不是 NUnit 的问题。

你好,
对于遇到此问题的任何人,我创建了一个简单的解决方案。
https://github.com/effyteva/Teva.Common.Cultures

你好!
也许这个解决方案对某人有用: https :

此页面是否有帮助?
0 / 5 - 0 等级