snapshooter icon indicating copy to clipboard operation
snapshooter copied to clipboard

Diff output instead of Assert.Equals

Open glucaci opened this issue 2 years ago • 2 comments

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.

glucaci avatar Sep 10 '21 09:09 glucaci

@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.

RohrerF avatar Sep 14 '21 06:09 RohrerF

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
         }
    }
    

jbockle avatar Jun 14 '23 12:06 jbockle