Skip to content

MS Test 2.2.4 - 2.2.10: Tests fail because DynamicData gets only structs with default values #1094

@gdir22

Description

@gdir22

Description

Hi,

I have a strange problem with MS Test versions 2.2.4 - 2.2.10. In my actual project a have a lot of unit tests that use DynamicData to fetch the test cases from a method. Up to MS Test 2.2.3 this worked fine. With MS Test 2.2.4 - 2.2.10 some (not all) of these tests fail, because the test cases are mixed up because all structs have default values. This seems to happen when structs are involved, but I'm not sure about that.

Steps to reproduce

I have prepared a minimal solution here: https://github.com/gdir22/Vector

There a four branches in the project:

Branch Vector2D is MS Test version Problem occurs
struct-mstest-2.2.3 struct 2.2.3 no
struct-mstest-2.2.10 struct 2.2.10 yes
class-mstest-2.2.3 class 2.2.3 no
class-mstest-2.2.10 class 2.2.10 no

Just switch the branches, build the solution and run the unit tests.

Expected behavior

All tests should pass.

Actual behavior

If Vector2D is a struct and MS Test version 2.2.10 (or any version after 2.2.3) is used, some of the test cases of the test method Vector2D_op_Multiplication_Vector2D_Vector2D___valid_Vector2D___double_scalar_product fail. They fail deterministically (always the same cases fail). If you debug the failing tests you will notice that the arguments of the test cases are mixed all structs have default values.

The arguments that the factory method sends are not the arguments that the test method receives.

The two other test methods, that are structured in the same way, don't show this behaviour. They pass in all combinations as expected. The same happens here.

Environment

Windows 10 21H2, Visual Studio 2019 or 2022, MS Test 2.2.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions