Only first DataRow gets executed in MSTest

927 Views Asked by At

I have a test with multiple DataRow(s). When executing test, it only runs first test

    [TestClass]
public class UnitTest1
{
    [DataTestMethod]
    [DataRow(1, 2, 3)]
    [DataRow(2, 3, 5)]
    [DataRow(3, 5, 8)]
    public void AdditionTest(int a, int b, int result)
    {
        Assert.AreEqual(result, a + b);
    }
}

enter image description here

Any idea if I am missing anything?

2

There are 2 best solutions below

0
Preston McCormick On

I was having the same problem, but only in the ReSharper Test Sessions window. If I ran the same tests from the Test Explorer window, all of the DataRow tests would run. It had previously worked in ReSharper as well. Before this started I had recently updated to MSTest 2.2.7 and changed the test project to use NuGet package references.

The problem was resolved by updating ReSharper to 2021.2.2.

0
Tom Ronayne On

If you're like me and were attempting to run a DataTestMethod on arrays, I think the issue is that visual studio will not run multiple DataRows with identical values, and "new float[]" is treated as the same value regardless of what its initialised to.

See more here: https://github.com/microsoft/testfx/issues/1016