【问题标题】:Getting parameters in integration testing MSTesting C#在集成测试中获取参数 MSTesting C#
【发布时间】:2017-02-22 09:06:58
【问题描述】:

我需要获取很多参数来动态构建测试方法。我的限制是它必须在 MSTest 和 C# 中。

我的想法是这样的:

[TestMethod]
public void test1 (int x, int y, string url, double l)
{
     // Use parameters here
}

我知道这是不可能的,我明白了。但这最终是我需要得到的。

谁能分享一些对此的见解?

【问题讨论】:

    标签: c# testing integration-testing mstest


    【解决方案1】:

    MSTest V2 中,您可以使用DataRowAttribute 执行此操作。例如:

    [TestMethod]
    [DataRow(1, 2, "http://kuku.com", 3.4)]
    [DataRow(4, 5, "http://foo.com", 6.7)]
    public void test1 (int x, int y, string url, double l)
    {
         // Use parameters here
    }
    

    这将导致测试运行两次,针对相应 DataRowAttribute 指定的每组值运行一次。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-07-03
      • 1970-01-01
      • 2016-06-08
      • 1970-01-01
      • 2016-05-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多