gpt4 book ai didi

c# - Nunit SetupUpFixture 语法

转载 作者:太空宇宙 更新时间:2023-11-03 11:27:23 25 4
gpt4 key购买 nike

尝试在 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 类的 SetUpTearDown 将为该命名空间中的所有类自动运行。

关于c# - Nunit SetupUpFixture 语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8931447/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com