stretchr / testify

A toolkit with common assertions and mocks that plays nicely with the standard library
MIT License
22.52k stars 1.56k forks source link

InEpsilonSlice doesn't append custom error message #1324

Closed bushkov closed 4 months ago

bushkov commented 1 year ago

Bug summary

When InEpsilonSlice takes a custom error message and the assertion fails, the custom message isn't displayed.

The issue is that in InEpsilonSlice implementation, msgAndArgs isn't passed to InEpsilon when iterating over slice elements:

https://github.com/stretchr/testify/blob/0ab3ce1249292a7221058b9e370472bca8f04813/assert/assertions.go#L1366

It should be:

result := InEpsilon(t, actualSlice.Index(i).Interface(), expectedSlice.Index(i).Interface(), epsilon, msgAndArgs...)

To reproduce

Write any test where InEpsilonSlice fails and takes a custom message. The message wouldn't be displayed.

dolmen commented 11 months ago

Here is a reproducer: https://go.dev/play/p/E-lLwVrMXym

myusko commented 4 months ago

Is an issue still relevant? I see mentions in the https://github.com/stretchr/testify/pull/1483 PR that was merged.

cc @arjunmahishi

brackendawson commented 4 months ago

The custom error message is still not shown, this issue is valid.

arjunmahishi commented 4 months ago

I've addressed it in #1548 along with the http assertions