I started to use MSTest 2 DataRow
attributes to check multiple cases in a single test:
[TestMethod]
[DataRow(1, 1, 2)]
[DataRow(1, 2, 3)]
public void AdditionWorks(int op1, int op2, int expectedResult)
{
Assert.AreEqual(expectedResult, new Sut().Add(op1, op2));
}
It works nicely, both in NCrunch and in CI. Only now I noticed that there is special attribute DataTestMethod
that is supposed to mark such tests instead of TestMethod
.
Is there a difference? A reason to use one variant in particular?