PlatformAttribute (NUnit 2.2.2)

平台属性用来指定一个测试或fixture运行的平台。使用无大小写之分的字符串来指定平台,也通过单独使用Include或Exclude属性在运行里包含或排除。包含的平台也可以指定为PlatformAttribute构造子的一个参数。不管是哪一种情况,可以指定多个逗号分隔的值。

Test Fixture语法

namespace NUnit.Tests
{
  using System;
  using NUnit.Framework;

  [TestFixture]
  [Platform("NET-2.0")]
  public class DotNetTwoTests
  {
    // ...
  }
}

Test语法

namespace NUnit.Tests
{
  using System;
  using NUnit.Framework;

  [TestFixture]
  public class SuccessTests
  {
    [Test]
    [Platform(Exclude="Win98,WinME")]
    public void SomeTest()
    { /* ... */ }
}

平台指定值

下面的值是可以识别的平台指定值。它们可以为大写,小写或者混合的。