-
-
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
Accept repeated views #38
Conversation
What do you think @rocboronat @SmasSive? I think the only cons are that the error message in case of exception would be different, and that the Barista code gets more complex. If you guys like it maybe we should apply this technique to other assertions as well. |
Wep @Sloy! Why not just catch the "MultipleMatchesException" and return green? |
There could be multiple matches for withText but be hidden |
I like your idea, could be a little tricky but I like more than Roc's because catching an exception to do something expected... Usually it's not a good idea because you know, an exception it's something unexpected. |
android:id="@+id/repeated_view_1" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:visibility="gone" |
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.
What do you think about adding a test that check that this TextView is invisible and the next ones visible? Just to check that the context that we're testing is the good one. If not, someone could remove this TextView, break your feature, and the tests will give a green instead of a red.
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.
I like the idea. But I think it should be part of the "Given" of the new test, instead of a new test. As you said, it's to verify the context of this test, not something independent. Agree?
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.
Totally... the thing is that I don't know if it's common to check the context in the "given" part instead of setting it. But... let's give it a try :·)
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.
Wep @Sloy how's the approach to this suggestion? It's something that we can do? Or it's too hard for this PR?
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.
Oh you're right. I thought I already did it! Let me add it real quick.
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.
Thanks! :·)
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.
@rocboronat how about now?
By the way, to save you a click to Travis:
|
Going to do the simplest job ever seen... :D |
Mmmmm @Sloy , what do you think about doing the same at |
@rocboronat yes, it's part of my first comment :P
|
Op, your comment was wider enough to understand that you're talking about lots of other assertions, not the other |
@rocboronat ok let's just go with displayed for now. |
By including the isDisplayed condition as a requirement for onView, we filter any views that matches the text but are not displayed. A bit tricky though.
Because the usage is different from allOf. It's not a matcher filter, but a view filter.
7c3b60d
to
3174754
Compare
Rebased with master! Definitive review? |
@@ -50,6 +50,14 @@ public void checkVisibleViews_breaksWhenNeeded() { | |||
} | |||
|
|||
@Test | |||
public void checkVisible_withRepeatedViews() throws Exception { | |||
assertNotDisplayed(R.id.repeated_view_1_gone); |
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.
Great way to check it! And so easy, I guess! :·D
@Sloy great! Feel free to merge it! :·) |
This is a solution proposal for #37
The trick is to combine
firstViewOf()
withallOf()
, and include the verification as a condition.Yeah, that crazy. But it should work.