Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSTest Named Parameters DataRow

It is possible to pass in data to a unit test using the DataRow attribute (in combination with the DataTestMethod attribute). However, I want to know if it is possible to pass in data to named parameters of the unit test.

For example, I would currently have to do:

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

Whereas, I would like to be able to:

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

I'm aware that this syntax is not 'feasible', it is more like pseudo code to convey my question.

like image 678
Ethan Avatar asked Dec 30 '25 15:12

Ethan


1 Answers

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

No, passing named parameters is not an available feature in the current version of MSTest.

like image 151
Nkosi Avatar answered Jan 01 '26 05:01

Nkosi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!