TestFixtureAttribute (NUnit 2.0)
这个属性标记一个类包含了测试,而且可选的还有setup或teardown方法。
作为一个测试fixture的类有一些限制。
- 必须是一个公共的导出类型,否则NUnit不会识别它。
- 它必须有一个缺省的构造子,否则Nunit不能构建他。
- 构造子不应该有任何方面的负面影响,因为在一个对话的过程中,NUnit可能构造类多次。
实例:
namespace NUnit.Tests
{
using System;
using NUnit.Framework;
[TestFixture]
public class SuccessTests
{
// ...
}
}
Imports System
Imports Nunit.Framework
Namespace Nunit.Tests
<TestFixture()> Public Class SuccessTests
' ...
End Class
End Namespace
#using <Nunit.Framework.dll>
using namespace System;
using namespace NUnit::Framework;
namespace NUnitTests
{
[TestFixture]
public __gc class SuccessTests
{
// ...
};
}
#include "cppsample.h"
namespace NUnitTests {
// ...
}
package NUnit.Tests;
import System.*;
import NUnit.Framework.TestFixture;
/** @attribute NUnit.Framework.TestFixture() */
public class SuccessTests
{
// ...
}