MSTest 命名参数数据行

MSTest Named Parameters DataRow

可以使用 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...
}

我知道这个语法不是'feasible',它更像是表达我的问题的伪代码。

I want to know if it is possible to pass in data to named parameters of the unit test.

否,传递命名参数在当前版本的 MSTest 中不可用。