Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diff output instead of Assert.Equals #136

Open
glucaci opened this issue Sep 10, 2021 · 2 comments
Open

Diff output instead of Assert.Equals #136

glucaci opened this issue Sep 10, 2021 · 2 comments

Comments

@glucaci
Copy link
Member

glucaci commented Sep 10, 2021

Is your feature request related to a problem? Please describe.
I would like to see a complete diff between actual and expected snapshot. Currently Assert.Equals is showing only the first position where the string is different.

Describe the solution you'd like
Using an known package DiffPlex we can print the entire snapshot diff in case when they are different.

@RohrerF
Copy link
Member

RohrerF commented Sep 14, 2021

@glucaci a first step into this direction would be made with #109. it's not a full diff but at least the lines where there is a mismatch. it's not perfect if your snapshot is wrong in more than one property, but at least something I guess.

aaronpowell added a commit to aaronpowell/snapshooter that referenced this issue May 5, 2023
Added a dependency on DiffPlex and changed the IAssert implementations so that when they fail, a diff is generated from the expected/actual and then that is used in the output. This makes it easier to see where there are problems between the two snapshots.

This addresses SwissLife-OSS#136
@jbockle
Copy link

jbockle commented Jun 14, 2023

regarding #183, Instead of displaying a diff/additional dependencies, could we shift to making snapshooter extensible, e.g.

  • with global events such as an event OnAssertionFailed event that can be globally handled, this could allow specific plugins to be created that could for instance open a diff tool of mismatch like Verify does for improved DX

  • static callbacks for assertions in case we wanted to customize the assertion message like

    public static class AssertionCallbacks
    {
         public delegate string GetFailedAssertionMessage(string expectedSnapshot, string actualSnapshot);
    
         public static GetFailedAssertionMessage GetFailedAssertionMessage {get;set;} = DefaultGetFailedAssertionMessage;
    
         private static string DefaultGetFailedAssertionMessage(string expectedSnapshot, string actualSnapshot)
         {
             // default message goes here
         }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants