尝试在 Nunit 中实现 SetUpFixture 功能时使用的正确语法是什么。这就是我所拥有的,但我不断收到错误消息:
namespace Testing
{
[SetUpFixture, RequiresSTA]
public class SetupClass
{
public IE CASsite = new IE("awebsite");
[SetUp]
public void Setup()
{
}
[TearDown]
public void TearDown()
{
CASsite.Dispose();
}
}
[TestFixture, RequiresSTA]
public class Tests : SetupClass
{
[Test]
public void DoSomething()
{
}
}
}
我不断收到的错误是:失败:SetupClass 中的 TestFixtureSetUp 失败
您是否为命名空间 Testing
定义了多个 SetUpFixture
?
根据文档,
Only one SetUpFixture should be created in a given namespace.
您的Tests
类派生自您的SetUpFixture
类。你不需要那样做。 SetUpFixture
类的 SetUp
和 TearDown
将为该命名空间中的所有类自动运行。
我是一名优秀的程序员,十分优秀!