我有一个TestFixture类,它派生自位于不同于TestFixture类的程序集中的基类。基类程序集包含任何命名空间之外的SetupFixture类。我希望SetupFixture的OneTimeSetup和onetimeeardown方法分别在运行开始和结束时运行一次,因为派生类继承自基类。但是,当我在派生类中执行测试时,SetupFixture OneTimexxx方法没有运行。为什么这样不行?
[SetupFixture]
public class SetupFixture // This is located in AssemblyA
{
[OneTimeSetUp]
public void MySetup()
{
Console.WriteLine("In Assembly Setup");
}
[OneTimeTearDown]
public void MyTeardown()
{
Console.WriteLine("In Assembly Teardown");
}
}
namespace AssemblyA
{
[TestFixture]
public class BaseTestClass // This is also in AssemblyA
{
[Setup]
public void MySetup()
{
Console.WriteLine("In Base Test Setup");
}
[TearDown]
public void MyTeardown()
{
Console.WriteLine("In Base Test Teardown");
}
}
}
namespace AssemblyB
{
[TestFixture]
public class MyTestClass : BaseTestClass // The derived class is in AssemblyB
{
[Test]
public void MyTest()
{
Console.WriteLine("In MyTest");
}
}
}
文章源自玩技e族-https://www.playezu.com/180922.html文章源自玩技e族-https://www.playezu.com/180922.html