square / assertj-android

A set of AssertJ helpers geared toward testing Android.
https://square.github.io/assertj-android/
Apache License 2.0
1.58k stars 156 forks source link

Add View tree traversal JQuery inspired assertions #56

Closed christopherperry closed 9 years ago

christopherperry commented 11 years ago

Was just writing a test and really wanted to write something like:

assertThat(viewGroup).has(textView).withText("fest!");

or perhaps

assertThat(viewGroup).has(TextView.class).withText("fest!");

is better design.

edenman commented 11 years ago

I like the latter.

christopherperry commented 11 years ago

@edenman I agree. I haven't poked around under the covers on this lib enough yet to know how easy this would be to accomplish, but I could take this on if others think this would be a good addition.

JakeWharton commented 11 years ago

Selectors naturally operate on arrays of objects whereas the assertions are tailored for a single element. I'd wager doing this properly would require a good bit of work.

WonderCsabo commented 10 years ago

I know this is an old issue, but if anyone interested, this can be achieved with the great espresso library.

JakeWharton commented 10 years ago

Espresso operates on top of Android's instrumentation. This library is for unit testing.

JakeWharton commented 10 years ago

Of course, it can also be used in your instrumentation as well.

WonderCsabo commented 10 years ago

Yeah, you are right, it cannot be used in simple unit tests. :( But i am a little bit confused about your two comments.

JakeWharton commented 10 years ago

I was just clarifying that this library can be used for both types of tests whereas Espresso can only be used for instrumentation tests.

JakeWharton commented 9 years ago

We have no plans for this. It's a fundamental deviation from the core principles of this library (which is itself merely a platform adapter for another library not offering anything along these lines).