Skip to content

DataTestMethod skips DataRows that provide different data arrays, only keeping last #1016

@sandersaares

Description

@sandersaares

Steps to reproduce

[DataTestMethod]
[DataRow(0, new int[] { })]
[DataRow(0, new int[] { 0 })]
[DataRow(0, new int[] { 0, 0, 0 })] // Is executed
[DataRow(1, new int[] { 1 })]
[DataRow(1, new int[] { 0, 1 })] // Is executed
public void TestMethod1(int expectedSum, int[] buckets)
{
    Assert.AreEqual(expectedSum, buckets.Sum());
}

Expected behavior

Test is executed with 5 sets of arguments.

Actual behavior

Test is executed with only 2 sets of arguments (see comments in snippet).

image

Test discovery DOES see all 5 test cases:

========== Starting test discovery ==========
========== Test discovery finished: 5 Tests found in 450,8 ms ==========
========== Starting test run ==========
========== Test run finished: 2 Tests (2 Passed, 0 Failed, 0 Skipped) run in 69 ms ==========

Environment

Windows 11, Visual Studio 2022 v17.0.1, .NET SDK 6.0.100.

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
    <PackageReference Include="MSTest.TestAdapter" Version="2.2.7" />
    <PackageReference Include="MSTest.TestFramework" Version="2.2.7" />
    <PackageReference Include="coverlet.collector" Version="3.1.0" />
  </ItemGroup>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions