One feature I've wanted to see in MSTest for a long time has been Parameterized Unit Tests (PUTs). I was excited to hear that Intellitest would be capable of creating said tests. I've started playing with Intellitest, however, and I'm thinking my definition of PUTs is different than Microsoft's.
When I think "PUT", I think TestCases in NUnit, or Theories in xUnit. People much smarter than me seem to use the same terminology.
Can someone tell me if Intellitest is actually capable of creating a PUT in the same way NUnit or xUnit might, or is this an issue of an overloaded term meaning one thing in Intellitest, and another to most other testing frameworks? Thanks.
As of June 2016, this feature has been added to "MSTest V2", which can be installed via NuGet by adding the MSTest.TestAdapter
and MSTest.TestFramework
packages:
Install-Package MSTest.TestAdapter
Install-Package MSTest.TestFramework
Be aware that these are different than the version of the test framework that ships with e.g. Visual Studio 2017. To use them, you'll likely need to remove the reference(s) to
Microsoft.VisualStudio.QualityTools.UnitTestFramework
.
Once these are installed, you can simply use the RowDataAttribute
, as demonstrated 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, you aren't restricted to
int
here. You can also usestring
,float
,bool
, or any other primitive value type.
This is identical to the implementation previously available to Windows Store App projects, if you're familiar with that.