[英]NUnit: SetUp and TearDown for each test in a test fixture across multiple Fixtures
I would like to have a generic SetUp and TearDown that is run with every test across multiple fixtures but all within a common namespace.我想要一个通用的 SetUp 和 TearDown,它在跨多个设备的每个测试中运行,但都在一个公共命名空间内。 This would be something similar to the [SetUpFixture] attribute but would be run with every test.
这将类似于 [SetUpFixture] 属性,但会在每个测试中运行。
I've tried using a base class with [SetUp] but resharper resolves this as inconclusive which isn't really ideal.我试过在 [SetUp] 中使用基类,但 resharper 将其解析为不确定的,这并不理想。
I don't see any problem in using a base class with the generic code.我认为将基类与通用代码一起使用没有任何问题。
public class BaseTest
{
[SetUp]
public void SetUp()
{
//Do generic Stuff
}
[TearDown]
public void TearDown()
{
// Do generic stuff
}
[TestFixture]
public class TestClass : BaseTest
{
[SetUp]
public void SetUp()
{
//Do Stuff
}
[TearDown]
public void TearDown()
{
// Do stuff
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.