IgnoreAttribute (NUnit 2.0)
Ignore属性一段时间内不会运行一个测试或者测试fixture。人们可以将一个测试或测试Fixture标记为Ignore属性。正在运行的程序看见了这个属性,不会执行一个或多个测试。
这个特性用来暂时不运行一个测试或fixture。比起注释掉测试或重命名方法,这是一个比较好的机制,因为测试会和余下的代码一起编译,而且在运行时有一个不会运行测试的标记,这样保证不会忘记测试。
Test Fixture语法
namespace NUnit.Tests
{
using System;
using NUnit.Framework;
[TestFixture]
[Ignore("Ignore a fixture")]
public class SuccessTests
{
// ...
}
}
Imports System
Imports Nunit.Framework
Namespace Nunit.Tests
<TestFixture(), Ignore("Ignore a fixture")>
Public Class SuccessTests
' ...
End Class
End Namespace
#using <Nunit.Framework.dll>
using namespace System;
using namespace NUnit::Framework;
namespace NUnitTests
{
[TestFixture]
[Ignore("Ignore a fixture")]
public __gc class SuccessTests
{
// ...
};
}
#include "cppsample.h"
namespace NUnitTests {
// ...
}
package NUnit.Tests;
import System.*;
import NUnit.Framework.TestFixture;
/** @attribute NUnit.Framework.TestFixture() */
/** @attribute NUnit.Framework.Ignore("Ignore a fixture") */
public class SuccessTests
{
// ...
}
Test语法
namespace NUnit.Tests
{
using System;
using NUnit.Framework;
[TestFixture]
public class SuccessTests
{
[Test]
[Ignore("Ignore a test")]
public void IgnoredTest()
{ /* ... */ }
}
Imports System
Imports Nunit.Framework
Namespace Nunit.Tests
<TestFixture()>
Public Class SuccessTests
<Test(), Ignore("Ignore a test")> Public Sub Ignored()
' ...
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][Ignore("Ignore a test")] void IgnoredTest();
};
}
#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.Ignore("ignored test") */
public void IgnoredTest()
{ /* ... */ }
}