Since June 2016, this feature has been added to " MSTest V2 ", which can be installed via NuGet by adding MSTest.TestAdapter and MSTest.TestFramework packages:
Install-Package MSTest.TestAdapter Install-Package MSTest.TestFramework
Keep in mind that they are different from the version of the test framework that comes with, for example, Visual Studio 2017. To use them, you probably need to remove the link (s) to Microsoft.VisualStudio.QualityTools.UnitTestFramework .
After installing them, you can simply use RowDataAttribute , as shown in the following example:
[TestMethod] [DataRow(1, 1, 2)] [DataRow(3, 3, 6)] [DataRow(9, -4, 5)] public void AdditionTest(int first, int second, int expected) { var sum = first+second; Assert.AreEqual<int>(expected, sum); }
Obviously, here you are not limited to int . You can also use string , float , bool or any other type of primitive value .
This is similar to the implementation previously available for Windows Store app projects if you are familiar with this implementation.
source share