android testing an overview of - oestrichandroid studio uses gradle, not much support for this yet
TRANSCRIPT
![Page 1: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/1.jpg)
An Overview of Android Testing
Eric Oestrich
BohConf7/19/2013
![Page 2: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/2.jpg)
Eric Oestrich
http://www.smartlogic.io
https://twitter.com/ericoestrich
https://github.com/oestrich
SmartLogic
![Page 3: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/3.jpg)
You can test Android?
![Page 4: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/4.jpg)
Regular Android testing leaves a lot to be
desired
![Page 6: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/6.jpg)
Run tests on your development machine
![Page 7: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/7.jpg)
JUnit 4
![Page 8: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/8.jpg)
Requires Maven
![Page 9: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/9.jpg)
IntelliJSupports maven projects
![Page 10: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/10.jpg)
EclipseShould just use IntelliJ
![Page 11: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/11.jpg)
Android StudioUses gradle, not much support for
this yet
![Page 12: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/12.jpg)
Downsides
![Page 13: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/13.jpg)
Content Providers are still hard to test
![Page 14: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/14.jpg)
Still somewhat newNot every area is able to be tested
nicely
![Page 15: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/15.jpg)
Lack of Documentation
![Page 16: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/16.jpg)
Extra Libraries You Should Consider
![Page 17: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/17.jpg)
Hamcresthttp://hamcrest.org/JavaHamcrest/
![Page 18: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/18.jpg)
Hamcrest● Nicer assertions than regular JUnit
![Page 19: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/19.jpg)
HamcrestassertThat(item.getId(), equalTo(itemId));
![Page 20: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/20.jpg)
FEST Androidhttps://github.com/square/fest-android
![Page 21: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/21.jpg)
FEST Android● Fluent assertions make test read nicely● FEST additions specific to Android
![Page 22: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/22.jpg)
FEST Android
assertThat(view.getVisibility(), equalTo(View.GONE));
vs
assertThat(view).isGone();
![Page 23: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/23.jpg)
Awaitilityhttps://code.google.com/p/awaitility/
![Page 24: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/24.jpg)
Awaitility● Handles testing asynchronous code nicely● Set timeouts
![Page 25: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/25.jpg)
Awaitilitypublic void testActivityTitle() {
await().atMost(TIMEOUT_SECONDS, TimeUnit.SECONDS).until(
activityTitle(), equalTo("Notification"));
Spoon.screenshot(getActivity(), "activity_title");
}
![Page 26: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/26.jpg)
Awaitilityprotected Callable<String> activityTitle() {
return new Callable<String>() {
@Override
public String call() throws Exception {
return mActivity.getTitle().toString();
}
};
}
![Page 27: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/27.jpg)
Spoonhttps://github.com/square/spoon
![Page 28: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/28.jpg)
Spoon● Take screenshots of app during test● Compiles to animated gif● Instrumentation tests
![Page 29: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/29.jpg)
Spoonpublic void testActivity() {
Spoon.screenshot(getActivity(), "activity");
}
![Page 30: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/30.jpg)
Spoon
http://square.github.io/spoon/sample/index.html
![Page 31: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/31.jpg)
Continuous Integration
![Page 32: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/32.jpg)
Jenkins Shell Scriptexport ANDROID_HOME=/var/lib/jenkins/tools/android-sdkmvn clean test --batch-mode
![Page 33: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/33.jpg)
Javadocs
![Page 34: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/34.jpg)
JUnit Results
![Page 35: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/35.jpg)
Android Emulator Pluginhttps://wiki.jenkins-ci.
org/display/JENKINS/Android+Emulator+Plugin
![Page 36: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/36.jpg)
Resources● http://corner.squareup.com/2013/05/robolectric-two-point-oh.html
● http://blog.bignerdranch.com/2583-testing-the-android-way/
![Page 37: Android Testing An Overview of - OestrichAndroid Studio Uses gradle, not much support for this yet](https://reader030.vdocuments.net/reader030/viewer/2022040619/5f2b9af6d8584522e531deb0/html5/thumbnails/37.jpg)
Questions?
http://www.smartlogic.io
http://www.twitter.com/smartlogic
http://www.github.com/smartlogic http://www.facebook.com/smartlogic