Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upMessage argument checking is inconsistent between functions #316
Comments
|
Hey @prashantv,
That's how it is supposed to work.
Sorry, I'm having a hard time understanding what you mean by this. Can you elaborate a bit more? |
Yes, I understand that, but my issue is more that when the user makes a mistake and passes multiple errors, the handling is different based on whether it's If you pass two errors by accident to This is an inconsistency, and I personally think both methods should ensure that when you do: assert.Error(t, err, someArg)The method should always ensure that |
|
@prashantv sorry it took long to reply, I have been very busy. Would you like to issue a PR changing every assertion to fail when the first element of |
|
@ernesto-jimenez Sure, I can take that on. |
|
awesome, thanks! |
|
This seems related to #119. |
References: * stretchr/testify#316 * stretchr/testify#119
References: * stretchr/testify#316 * stretchr/testify#119
References: * stretchr/testify#316 * stretchr/testify#119
References: * stretchr/testify#316 * stretchr/testify#119
References: * stretchr/testify#316 * stretchr/testify#119


I recently ran into an issue where we accidentally passed two different errors to
require.NoError:It was incorrectly testing the previous
errinstead of the output of callingTestFunc(). I've noticed thattestifyis inconsistent between whether it checks the arguments before checking if the condition failed, or whether it's only checked if the condition fails.I've written a couple of simple tests to show the difference:
In both cases, we're passing two errors -- the second is what we actually want to compare. However, the first error we pass would pass the assertion, while the second is the one we intended, and would cause the assertion to fail.
The output of
TestRequireErr:The output of
TestRequireNoErr:I think both assertions should be consistent -- and ideally, they both ensure that the
msgis actually a string regardless of the condition, since the compiler can't enforce this.