testify icon indicating copy to clipboard operation
testify copied to clipboard

Inconsistent nature of `messageFromMsgAndArgs`

Open Antonboom opened this issue 11 months ago • 7 comments

Description

Hello, team!

I was surprised, but testify allows to set non-string in msgAndArgs... if this is the single argument:

https://github.com/stretchr/testify/blob/89cbdd9e7b39eb58896d316a7495597d3aba4371/assert/assertions.go#L290-L296

So I can do

assert.Equal(a, b, new(time.Time))

But cannot

assert.Equal(a, b, new(time.Time), 1, 2, 3) // Panics.

Proposed solution

Remove support of non-string single arg (as rare and strange? case) and allows only msg string + args ...any.

Use case

f-assertions future (https://github.com/stretchr/testify/issues/1089#issuecomment-1695059265).

Antonboom avatar Nov 13 '24 21:11 Antonboom