NUnit,针对多种文化进行测试 [英] NUnit, testing against multiple cultures

查看:61
本文介绍了NUnit,针对多种文化进行测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望使用 NUnit 在某个项目中针对多种文化运行所有测试.

Using NUnit I wish to run all the tests in a certain project against multiple cultures.

该项目处理应该是文化中性的解析数据,以确保这一点,我想针对多种文化运行每个测试.

The project deals with parsing data that should be culture neutral, to ensure this I would like to run every test against multiple cultures.

我目前的解决方案是

public abstract class FooTests {
    /* tests go here */
}

[TestFixture, SetCulture ("en-GB")] public class FooTestsEN : FooTests {}
[TestFixture, SetCulture ("pl-PL")] public class FooTestsPL : FooTests {}

理想情况下,我不应该创建这些类,而是使用类似的东西:

Ideally, I shouldn't have to create these classes and instead use something like:

[assembly: SetCulture ("en-GB")]
[assembly: SetCulture ("pl-PL")]

推荐答案

很遗憾,现在无法实现,但计划在未来进行.

Unfortunatelly this isn't possible now but is planned for future.

你也可以这样做.

public class AllCultureTests
{
  private TestSomething() {...}

  [Test]
  [SetCulture("pl-PL")]
  public void ShouldDoSomethingInPoland()
  {
    TestSomething();
  }
}

也许这是您更喜欢的?

这篇关于NUnit,针对多种文化进行测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆