Barista
Barista copied to clipboard
Improve assertion error messages by adding mismatch descriptions
I added overrides for TypeSafeMatcher.describeMismatchSafely() to improve the error messages that Barista gives when the assertion fails
Hi @angusholder
Any example on how error messages looked before this PR and how it looks with this change?
Weren't there some tests for the assertion messages? I don't know what's the current status of CI
Hi @angusholder
Any example on how error messages looked before this PR and how it looks with this change?
For assertErrorDisplayed
it was previously displaying the mismatch value by calling View.toString()
, like so:
Caused by: junit.framework.AssertionFailedError: 'with error: My error message 123' doesn't match the selected view. Expected: with error: My error message 123 Got: was <com.google.android.material.textfield.TextInputLayout{a8f4ca1 V.ED..... ........ 0,0-560,219 #7f0a01b8 app:id/my_view_id aid=1073741835}>
Now it displays what TextView.getError()
was instead:
Caused by: junit.framework.AssertionFailedError: 'with error: "My error message 123"' doesn't match the selected view. Expected: with error: "My error message 123" Got: with error: "Some other error message 456."
Look much better!
Is there any way, btw, to avoid this ñart?
Caused by: junit.framework.AssertionFailedError: 'with error: "My error message 123"' doesn't match the selected view.
Look much better!
Is there any way, btw, to avoid this ñart?
Caused by: junit.framework.AssertionFailedError: 'with error: "My error message 123"' doesn't match the selected view.
What do you want it to say instead? I think that part is created by JUnit and Hamcrest