Skip to content

Snapshots from tests using IgnoreParametersForVerified aren't handled correctly #5

Description

@aaron-meyers

When using 'IgnoreParametersForVerified' in a parameterized test, dotnet verify review or accept will create a new .verified.* file that includes the parameters rather than writing over the existing .verified.* file that excludes them. Was this intended? If the matching .verified.* file does not exist already, I believe it should be safe to look for an existing .verified.* file that excludes the parameter portion of the filename - since a failing test creates the corresponding .verified.* file when it doesn't exist it seems like this shouldn't cause issues.

Example test:

    [Theory]
    [InlineData(1, 0)]
    [InlineData(0, 1)]
    [InlineData(-1, 2)]
    public async Task AddsUpTo1(int value1, int value2)
    {
        int result = value1 + value2;
        await Verify($"result is {result}").IgnoreParametersForVerified(value1, value2);
    }

Repro steps:

  1. Run the test above - test fails and creates the following files:
    a. .AddsUpTo1.verified.txt
    b. .AddsUpTo1_value1=0_value2=1.received.txt
    c. .AddsUpTo1_value1=1_value2=0.received.txt
    d. .AddsUpTo1_value1=-1_value2=2.received.txt
  2. Run dotnet verify review and accept new snapshots - rather than writing over the .AddsUpTo1.verified.txt file, it replaces the .received.* files with corresponding .verified.* files:
    a. .AddsUpTo1_value1=0_value2=1.verified.txt
    b. .AddsUpTo1_value1=1_value2=0.verified.txt
    b. .AddsUpTo1_value1=-1_value2=2.verified.txt

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