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
Assertion errors given to the user only contain the string representation of values #12892
Comments
Following is how the assertion comparison is done in JUnit5. If there is a type mismatch, the errors are shown as follows.
When the types are matched, but the values are different, the errors are shown as follows.
In the following 2 examples, only the type of the property 'age' is different.
|
Following is how the assertion comparison is done in GoLang. If there is a type mismatch, the errors are shown as follows.
When the types are matched, but the values are different, the errors are shown as follows.
The function is as follows.
|
IMO the diff based approach used in GoLang is much useful compared to the approach in JUnit5. WDYT? |
Following is how the assertion comparison is done in TestNG. Same limitation of not showing the type mismatch as mentioned in this issue is present in TestNG too.
|
I agree, the diff approach leaves no room for guessing what actually went wrong. But that would only work for |
@pubudu91
Appreciate if you can share some examples where this might not be possible in the context of Ballerina. So, that I can understand it clearly. |
Now that "assertEquals" function accepts only anydata type values, we can show the diff when there is an assertion failure. |
Assertion failure can be handled in following 2 parts.
|
Assertion diff for other data types will be addressed in #26204 |
When an assertion error occurs, it only uses the string representations of the values to communicate the error to the user. However, if the string representation is the same, but the types are different, the assertion still fails, but the user will be confused as to why the assertion failed when the two values are seemingly the same. Consider the following sample error which was a result of a type mismatch.
The text was updated successfully, but these errors were encountered: