【问题标题】:Strange constructor behaviour in nunit parameterized testsnunit参数化测试中的奇怪构造函数行为
【发布时间】:2013-05-07 08:06:36
【问题描述】:

我有一个 nunit 2.5.10 参数化测试:

[TestFixture(parameter1)]
[TestFixture(parameter2)]
public class MyTest : BaseTest
{
   var param="";

   public MyTest(string arg)
   {         
       param=arg;
   }

   [Test]  
   public Test()
   {
      //... test stuff
   }
}

在带有 Resharper 7.0.1 的 VS 12 中,我只运行一个夹具 但是! 构造函数被调用 两次 - 一次在测试执行之前(针对一个参数),然后在之后测试执行,但对于另一个参数。为什么?只有构造函数被调用了两次,测试本身是否按预期运行 - 只有一次。

【问题讨论】:

  • 这在 NUnit GUI 中是一样的吗?

标签: nunit resharper


【解决方案1】:

这是一个已知问题,不幸的是,请参阅RSRP-336641“在参数化 TestFixture 上调用某些案例时,所有案例的构造函数和 TestFixtureSetUp 都会被调用。”

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-24
    相关资源
    最近更新 更多