2

I have test function:

[TestMethod()]
public void CreateTest(string input)
{
   string expected = "321"; 
   Assert.AreEqual(expected, input);
}

I need to run this test with different data: CreateTest("321"); CreateTest("123"); CreateTest(null); I do not know how to do this before I did something like [TestCase("123")], [TestCase("321")]

I need something that:

[RowTest]
[Row(1,1,2)]
[Row(2,1,3)]
[Row(1,-1,0)]
public void SumTest(int a1, int a2, int result)
{
    Assert.AreEqual(a1 + a2, result);
}
Sergey Berezovskiy
  • 232,247
  • 41
  • 429
  • 459
Mediator
  • 14,951
  • 35
  • 113
  • 191

1 Answers1

1

Have you tried data-driven unit testing? It doesn't use class attributes, but it should give you the same results.

If you want to achieve high code coverage, take a look at the Pex power tool.

If you want to model your tests (MBT), Spec Explorer is also worth review.

SliverNinja - MSFT
  • 31,051
  • 11
  • 110
  • 173