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

With text barista #388

Merged
merged 9 commits into from
Jul 5, 2021
Merged

With text barista #388

merged 9 commits into from
Jul 5, 2021

Conversation

alorma
Copy link
Member

@alorma alorma commented Mar 11, 2021

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 for TextView or TextInputLayout in order to check it's text and does the same validations of withText

I cannot reuse what withText() does, because matcher WithTextMatcher constructor is private

@alorma alorma force-pushed the withText_barista branch from d46995b to 097b721 Compare March 11, 2021 12:49
@alorma alorma marked this pull request as ready for review March 11, 2021 12:57
@alorma alorma requested a review from Sloy March 11, 2021 12:57
assertNotDisplayed(R.id.hintanderror_inputlayout, "Other test text")
}

@Test(expected = BaristaException::class)
Copy link
Member

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");
  }

Copy link
Member Author

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

@alorma alorma force-pushed the withText_barista branch from 19f31f8 to b7671d6 Compare March 23, 2021 15:13
@rocboronat
Copy link
Member

Hello! 👋 Just a kind reminder about this lovely and very useful PR 👯

@alorma alorma force-pushed the withText_barista branch from 1c9ab7b to 302da2a Compare May 27, 2021 08:41
@alorma alorma marked this pull request as draft May 27, 2021 08:45
@rocboronat rocboronat added the wip label May 27, 2021
@alorma alorma force-pushed the withText_barista branch from c9efd9c to ea30924 Compare June 1, 2021 09:54
@alorma alorma marked this pull request as ready for review June 1, 2021 13:53
@alorma alorma removed the wip label Jul 1, 2021
@alorma alorma enabled auto-merge (squash) July 5, 2021 08:46
@alorma alorma force-pushed the withText_barista branch from 59d77d2 to c77cbdb Compare July 5, 2021 08:48
@alorma alorma merged commit dcc9469 into master Jul 5, 2021
@alorma alorma deleted the withText_barista branch July 5, 2021 09:28
Sloy pushed a commit to DeanPike/Barista that referenced this pull request Jul 5, 2021
* Create withCompatText

* Move all withText(String) to withCompatText(String)

* Add tests

* Use custom matchers, no need to creater one

* Fix  tests

* Fix test
Sloy added a commit that referenced this pull request Jul 5, 2021
#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]>
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.

3 participants