-
-
Notifications
You must be signed in to change notification settings - Fork 120
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
With text barista #388
With text barista #388
Conversation
d46995b
to
097b721
Compare
library/src/main/java/com/schibsted/spain/barista/internal/matcher/TextMatcher.kt
Outdated
Show resolved
Hide resolved
library/src/main/java/com/schibsted/spain/barista/internal/matcher/TextMatcher.kt
Outdated
Show resolved
Hide resolved
assertNotDisplayed(R.id.hintanderror_inputlayout, "Other test text") | ||
} | ||
|
||
@Test(expected = BaristaException::class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could test the exception more explicitly, to check that the error message is right.
Like this one from ListClickTest:
@Test
public void fail_whenNoViewFound() {
launchTestActivity(ListsActivity.buildIntent());
Throwable thrown = catchThrowable(() -> clickListItem(20));
spyFailureHandlerRule.assertEspressoFailures(1);
assertThat(thrown).isInstanceOf(BaristaException.class)
.hasMessage("No ListView or RecyclerView found in the hierarchy");
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhmm, it's a generic error message.. not sure if I will add a custom message here
19f31f8
to
b7671d6
Compare
Hello! 👋 Just a kind reminder about this lovely and very useful PR 👯 |
* Create withCompatText * Move all withText(String) to withCompatText(String) * Add tests * Use custom matchers, no need to creater one * Fix tests * Fix test
#354) * Fix issue #283 assertDisplayedAtPosition doesn't assert displayed list view I removed the scrollListToPosition from assertDisplayedAtPosition as it is done in assertCustomAssertionAtPosition. isShowOnScreen checks to see if the view is visible to the user. getShownViewsById retuns a list of all views that match the viewId and are visible to the user. * Fix tests * With text barista (#388) * Create withCompatText * Move all withText(String) to withCompatText(String) * Add tests * Use custom matchers, no need to creater one * Fix tests * Fix test Co-authored-by: Rafa Vázquez <[email protected]> Co-authored-by: Roc Boronat <[email protected]> Co-authored-by: Bernat Borrás Paronella <[email protected]>
From #387
As espresso uses:
class WithTextMatcher extends BoundedMatcher<View, TextView>
All asserts build on top of withText() (like assertDisplayed(), assertContains(), ...) will fail.
I've created a
withCompatText
that checks forTextView
orTextInputLayout
in order to check it's text and does the same validations ofwithText
I cannot reuse what
withText()
does, because matcherWithTextMatcher
constructor is private