可以使用 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...
}
我知道这种语法不“可行”,它更像是传达我的问题的伪代码。
最佳答案
I want to know if it is possible to pass in data to named parameters of the unit test.
不,传递命名参数不是当前版本的 MSTest 中的可用功能。
关于c# - MSTest 命名参数数据行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49298668/