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
{
// ...
}
}
Imports System
Imports Nunit.Framework
Namespace Nunit.Tests
<TestFixture(), Platform("NET-2.0")>
Public Class DotNetTwoTests
' ...
End Class
End Namespace
#using <Nunit.Framework.dll>
using namespace System;
using namespace NUnit::Framework;
namespace NUnitTests
{
[TestFixture]
[Platform("NET-2.0")]
public __gc class DotNetTwoTests
{
// ...
};
}
#include "cppsample.h"
namespace NUnitTests {
// ...
}
package NUnit.Tests;
import System.*;
import NUnit.Framework.TestFixture;
/** @attribute NUnit.Framework.TestFixture() */
/** @attribute NUnit.Framework.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()
{ /* ... */ }
}
Imports System
Imports Nunit.Framework
Namespace Nunit.Tests
<TestFixture()>
Public Class SuccessTests
<Test(), Platform(Exclude="Win98,WinME")> Public Sub SomeTest()
' ...
End Sub
End Class
End Namespace
#using <Nunit.Framework.dll>
using namespace System;
using namespace NUnit::Framework;
namespace NUnitTests
{
[TestFixture]
public __gc class SuccessTests
{
[Test][Platform(Exclude="Win98,WinME")] void SomeTest();
};
}
#include "cppsample.h"
namespace NUnitTests {
// ...
}
package NUnit.Tests;
import System.*;
import NUnit.Framework.TestFixture;
/** @attribute NUnit.Framework.TestFixture() */
public class SuccessTests
{
/** @attribute NUnit.Framework.Test() */
/** @attribute NUnit.Framework.Platform(Exclude="Win98,WinME") */
public void SomeTest()
{ /* ... */ }
}
平台指定值
下面的值是可以识别的平台指定值。它们可以为大写,小写或者混合的。
- Win
- Win32
- Win32S
- Win32Windows
- Win32NT
- WinCE
- Win95
- Win98
- WinMe
- NT3
- NT4
- NT5
- Win2K
- WinXP
- Win2003Server
- Unix
- Linux
- Net
- Net-1.0
- Net-1.1
- Net-2.0
- NetCF
- SSCLI
- Rotor
- Mono