MSTest命名参数DataRow

时间:2018-03-15 11:47:50

标签: c# unit-testing mstest

可以使用DataRow属性(结合DataTestMethod属性)将数据传递到单元测试。但是,我想知道是否可以将数据传递给单元测试的命名参数。

例如,我现在必须这样做:

[DataTestMethod]
[DataRow(1, null, 3)]
public void MyTest(int? first = null, int? second = null, int? third = null)
{
    // Test stuff...
}

然而,我希望能够:

[DataTestMethod]
[DataRow(first: 1, third: 3)]
public void MyTest(int? first = null, int? second = null, int? third = null)
{
    // Test stuff...
}

我知道这种语法不“可行”,它更像是伪代码来传达我的问题。

1 个答案:

答案 0 :(得分:0)

  

我想知道是否可以将数据传递给单元测试的命名参数。

不,传递命名参数不是当前版本的MSTest中的可用功能。