12

In Nunit one can reuse a test method for multiple cases.

[TestCase(12,3,4)]
[TestCase(12,2,6)]
[TestCase(12,4,3)]
public void DivideTest(int n, int d, int q)
{
  Assert.AreEqual( q, n / d );
}

How can I do this in Visual Studio's test framework?

StuartLC
  • 100,561
  • 17
  • 199
  • 269
Colonel Panic
  • 126,394
  • 80
  • 383
  • 450
  • Possible duplicate of [Does MSTest have an equivalent to NUnit's TestCase?](http://stackoverflow.com/questions/1010685/does-mstest-have-an-equivalent-to-nunits-testcase) – Ian Kemp Feb 03 '17 at 10:29

2 Answers2

3

It is not possible out of the box. But for VS 2010 atleast you can write MSTEST Extensions to provide nearly the same feature. Check this blog. But it is not nearly as good as NUnit's TestCase.

Ganesh R.
  • 4,312
  • 3
  • 26
  • 45
2

Unfortunately, MS Test doesn't support RowTests. However, a workaround can be hacked using the DataSource attribute. There is an example here.

Community
  • 1
  • 1
StuartLC
  • 100,561
  • 17
  • 199
  • 269