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 compatibility with older SDKs #36

Closed ry4n1m3 closed 11 years ago

ry4n1m3 commented 11 years ago

We set IntelliJ to SDK level 2.3.3 so that we don't get autocompletes for more modern APIs that aren't going to be available on older phones, but when we do that we get mysterious looking errors for matchers that handle things like android.animation.Animator which didn't exist in 2.3.3. We had the same problem when we didn't link against the support library. When we ran into this on Robolectric we solved it by having multiple versions of classes that were supersets of each other, so there could be ANDROID10.assertThat and ANDROID16.assertThat. It was a little ugly looking to implement, but it's been convenient to use. Maybe Fest-Android could do something similar.

Alternatively, there could be a "legacy" branch or fork of fest-android that catered to the older API levels.

Phil & Dave

JakeWharton commented 11 years ago

ANDROID.java is generated programmatically from the generate-android-java.py script. I suppose you could make it generate ANDROID1.java, ANDROID4.java, etc. all of which extend from each other. You could even do this as a standalone artifact which just depends on this one. We won't be able to support this in the project, however, as it's too much work for too little reward. The recommendation of the Google Android team (and ours) is to use the latest APIs and use lint to guard against calling newer APIs when you don't mean to.