testify icon indicating copy to clipboard operation
testify copied to clipboard

Assert.Equal show only diff

Open wmcnamee-coreweave opened this issue 1 year ago • 2 comments

Description

Wondering if there's a way to show only the diff and not this part:

Error:      	Not equal:
        	            	expected: ...
        	            	actual ...

I have large yaml strings I'm comparing, and this part of the test output is completely useless. The diff looks fine though.

Proposed solution

Use case

wmcnamee-coreweave avatar Jul 23 '24 22:07 wmcnamee-coreweave

That's currently not possible with any of the assertion functions. That formatted string always gets returned.

https://github.com/stretchr/testify/blob/v1.9.0/assert/assertions.go#L466-L469

I agree that tends to not be helpful for large strings and interfaces.

As a side note for your use case: The assertions package also hasYAMLEq

tscales avatar Aug 27 '24 15:08 tscales

I also dislike scrolling past a large object twice to get to the diff. But I sometimes copy and paste the objects into a better diff viewer. I'd support a change that moved the diff to the top.

brackendawson avatar Sep 30 '24 10:09 brackendawson