Skip to content
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

Improve assertion error messages by adding mismatch descriptions #461

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

angusholder
Copy link

I added overrides for TypeSafeMatcher.describeMismatchSafely() to improve the error messages that Barista gives when the assertion fails

@Sloy Sloy requested a review from a team November 16, 2022 09:57
@alorma
Copy link
Member

alorma commented Nov 16, 2022

Hi @angusholder

Any example on how error messages looked before this PR and how it looks with this change?

@Sloy
Copy link
Member

Sloy commented Nov 16, 2022

Weren't there some tests for the assertion messages? I don't know what's the current status of CI

@angusholder
Copy link
Author

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."

@alorma
Copy link
Member

alorma commented Nov 28, 2022

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.

@angusholder
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants