Unit test frameworks other than Microsoft have options to add input parameters and expected results using attributes.
For example,
NUnit has
[TestCase(12,4,3)]
and xUnit has
[InlineData(5, 1, 3, 9)]
What's the Microsoft way to accomplish this?
You need to add Nuget packages MSTest.TestFramework and MSTest.TestAdapter (for discovery of tests) and remove the reference of Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
which is added by default. You are good to go to add input parameters:
[TestMethod]
[DataRow(10)]
[DataRow(20)]
[DataRow(30)]
public void TestMethod1(int inputValue)
{
Assert.AreEqual(10, inputValue);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With