-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow overloaded verify() method that takes arbitrary text message #202
Comments
Hi! Thanks for reporting this. You say you would most often use it with the Can you give me an example of where adding your own text would be useful? |
If the error message always included the getSimpleName then that would certainly go a long way to making my life easier, but I was slightly wary of suggesting just that, in case making that change affected existing users of the library in some way I hadn't thought of. My full use case is that I have a table of classes that my test has to loop over, using EqualsVerify on each, and without having the name of the class in the message, I can't tell which class actually has a problem. The table of classes to be tested is built outside of the test (something akin to a plug-in architecture), and sometimes different plug-in providers use the same simpleName for their class. Whilst the full class name is unique, that is often very verbose, and I'd rather build a distinct but short string from the plug-in reference and the simpleName, and provide that as an arbitrary string. |
That sounds like a good use case, and adding the simpleName in every error message shouldn't be a problem. It could indeed theoretically affect existing users, so I'll include it in the next major release (which I'm already working on). |
I've just released version 3.0, where the simpleName is now included in all error messages. |
Please provide any additional information below.
In most testing frameworks, the assert call comes in two varieties: assert(condition) and assert(message, condition), where the message gets included in the output if the condition fails.
In EqualsVerify, the verify() call is effectively the same as an assert call, but this only comes in a single variety.
It would be most useful if I could call verify with an arbitrary text message that was used as a prefix for any exception that the test throws.
(In practice, the most common use of this message would likely be to pass in foo.class.getSimpleName() when testing foo.class, but I recognize that not everyone would want this as the default, hence the suggestion to allow an arbitrary message).
The text was updated successfully, but these errors were encountered: