USING JAVA TOOLS�BEEF UP ANDROID APPS�
Stéphane Nicolas & Jérôme Van Der Linden
Jerome Van Der Linden�
android-‐holo-‐colors.com
2
@jeromevdl +jerome van der linden jeromevdl
Stéphane Nicolas�
BoundBox
And others : RoboDemo, Quality Analysis Tools for Android, android-‐maven-‐plugin, …
3
+stephane nicolas snicolas stephanenicolas
4
JAVA ENVIRONMENT�
ONCE UPON A TIME �15
6
4
Everything is testable ��
Everything is measurable ��
Everything is integrated���
No excuses to have poor apps ! �
7
Great ! �
8
And me ?! �
9
2 WTF ?! �
ANDROID IS JAVA ! �
10
Almost YES… �
… a story of �Virtual Machine �
So what … ?�
11
12
3
Oh Yeah ! �
(almost) Everything is testable ��
(almost) Everything is measurable ��
BUT��
Everything is NOT integrated������
14
Quality Tools for Android��
http://goo.gl/zGFvda�
15
3 Quality Tools Android �
Ant�
16
4 Quality Tools Android �
Maven �
18
<plugin> ! <groupId>com.jayway.maven.plugins.android.generation2</groupId>"! <artifactId>android-maven-plugin</artifactId> ! <version>3.6.1</version> !</plugin> !
The magical� plugin�
19
The ultimate � profile �
# run junit, robotium, robolectric tests and get code coverage!> mvn clean install –P jacoco!
20
Maven Profiles
Junit + Robo,um Robolectric UIAutomator Code
coverage
Quality checks
(Checkstyle + findbugs + PMD + lint)
Sonar
standard
emma
cobertura
ui automator
spoon
jacoco
21
x2
22
hOps://github.com/SonarCommunity/sonar-‐android
# analyse code (pmd, checkstyle, findbugs, lint) and report in sonar !> mvn sonar:sonar –P jacoco!
Android Lint �Sonar plugin�
Not an archetype �(see akquinet : http://goo.gl/O46LIw) �
�Only samples �
�Do not use everything ! �
�Pick up what you need ! �
23
Return of �real life experience �
Maven Jenkins Sonar (PMD, checkstyle, findbugs, lint) Junit (Instrumenta[onTestCase)
~ 100 screens (phone + tablet) ~ 5 developers during only 5 months ~ 60k loc (java), 15k loc (xml) ~ 400 unit tests : not an excep[onal coverage (~ 30%) Built on each commit on Jenkins + Genymo[on 0 lint, pmd, findbugs, checkstyle viola[ons 1 sonar report generated each night with those metrics è An happy customer J
24
A laborious development environment : eclipse + maven + m2eclipse + android m2e connector è Many hours lost è Use IntelliJ !
A laborious execu[on environment : emulator è Too slow è Use Genymo[on (or at least a device) ! Not enough tests : è Instrumenta[onTestCase are too heavy/slow for Unit Tes[ng è Use Robolectric and/or think about MV* paOern è Keep Instrumenta[onTestCase for Android specific (Ac[vity, Services, …)
Lessons � learned�
25
A robust development environment : eclipse + maven + m2eclipse + android m2e connector è s[ll some problem with eclipse and maven integra[on About tests è Instrumenta[onTestCase are fast enough with GenyMo[on è Robolectric can’t give you enough confidence
Lessons � learned�
26
5 Quality Tools Android �
Gradle �
27
Lint ��
UIAutomator��
Monkey & Monkey Runner ��
Robolectric ��
PMD, checkstyle, findbugs ��
Emma, Cobertura, Jacoco �
28
Before V 0.6
Joke ?! �
Lint ��
UIAutomator��
Monkey & Monkey Runner ��
Robolectric ��
PMD, checkstyle, findbugs ��
Emma, Cobertura, Jacoco �
30
V 0.6.+
31
Quality �the gradle way�# run junit, robotium, robolectric tests !# AND Chekstyle + PMD + Findbugs + Classycle !> gradle check!# report in sonar !> gradle sonarRunner!
6 Conclusion�
Android is filling the gap�
32
33
Feature Gradle Maven
Application Variants & Manifest merging ?
Standard tests & Robo,um
Code Coverage
Robolectric
UI automator / Monkey / Monkey Runner
PMD / CheckStyle / FindBgugs / Classycle / Lint
Sonar & Project Sites
Gradle0.6.1 VS Maven3.6.1�
34 Android offers ��
lots of quality tools ��
lots of testing methods ��
rapid testing��
Everything gets easier to use�
�Build rock solid apps �
Thank You ! �
Any Question ?� Stéphane Nicolas & Jérôme Van Der Linden
35
@jeromevdl +jerome van der linden jeromevdl
+stephane nicolas snicolas stephanenicolas
Quality Tools for Android��
http://goo.gl/zGFvda�
36