Building High Quality Android
            Apps
  By using Jenkins and Automated Device
                    Tests
Getting to know each other...

Leif Janzik
Team-Lead Android Development
adesso mobile solutions GmbH

Twitter: @ElliotMonster
Blog: www.thoughtsonmobile.com
About adesso mobile solutions GmbH

•   adesso mobile solutions GmbH, Dortmund, 65 MA (Ende 2012)
•   Tochterunternehmen der adesso AG, Dortmund, ca. 1.100 MA
    (Ende 2012)
•   führender Anbieter in den Bereichen mobiles Internet, mobile
    Applikationen und Mobile Marketing
•   Portfolio: Beratung, Konzeption, Realisierung, Review, Test und
    Betrieb von Mobilisierungs-Projekten und App-Lösungen
•   Kunden: Über 200 realisierten Portalen und Applikationen für
    Kunden wie Daimler, PAYBACK, ERGO, süddeutsche.de,
    SportScheck, die Volksbanken Raffeisenbanken, Bundesagentur
    für Arbeit.
So you are an Android Developer
 and everything is f***ing awesome...



http://www.flickr.com/photos/fullcodepress/
Everyone loves your Apps



http://www.flickr.com/photos/fullcodepress/
Your companies headquarter
looks like these



http://www.flickr.com/photos/fullcodepress/
Everything is perfect!



http://www.flickr.com/photos/fullcodepress/
BUT

http://www.flickr.com/photos/fullcodepress/
... time goes on, and the apps evolves,
new features, new API-levels, bugfixes etc.
http://www.flickr.com/photos/fullcodepress/
There are „some“ new devices ...
... every day
http://www.flickr.com/photos/fullcodepress/
And after some Versions, Refactorings
& new Features your Code looks more like this...
you try to keep everything fine
and running...
... but the number of bugs
continues to grow ...
maybe your customers will react
like this?
... but more likely they will
react like this ...
... Your companies new
headquarter ...
... and being a Android Developer
is no fun no more.
Ok, maybe I exagerated a bit, BUT

•   Android Apps grow more and more complex
•   Customers expect a bugfree and undisturbed App
    experience
•   Tolerance even for minor bugs continues to shrink
•   Device fragmentation makes testing a sisysphean task
Some „everyday-problems“ we had to solve

•   Apps have to be build in many different Versions (e.g.
    Development/Staging-Enviroment) or different brandings
•   Developers are often disturbed, e.g. when a AdHoc for the
    customer is needed
•   Changes in App Components lead to new bugs, which
    were discovered later.
so what is the solution to this problem?
exessive Testing ...
but testing your own app is
soooooo boring! (so it might be skipped or not done thoroughly)
that‘s why we automated much of
our testing and our build process.
„Our“ solution

•   a clean and reliable development workflow
•   a toolchain which supports the developers and keeps
    disturbing work away
•   Continuous refactoring of the apps
•   Maven for lesser configuration for every developer and
    easier modularisation
•   Automated Device Tests
•   Continuous integration
What is Continuous Integration?
• Automate everything

• Build as often as possible
    • Build early, build often
    • e.g. on every commit
    • or nightly builds
Benefits of Continuous Integration
• Fewer Errors
   • very important, not everybody installs every update, so
      bugs might never be fixed on a customers device
• Fast Feedback
• Tests everything on every (nightly) build
• Much less manual testing
   • Cheaper
   • Happier developers
• Regression-Tests without additional effort
Automate...
• ...Builds
• ...Unit Testing
• ...Device Tests
• ...Code Coverage & Static Analysis
• ...Deployment
3 Major Build Profiles

Build after Commit        Nightly Build           Release or Promoted Build
• Build and archive APK   • Build Project         •   Build APK
• Run Unit-Tests            without               •   Run Unit-Tests
• Run Sonar Code            archiving/publishin   •   Run Calabash Tests
  Metrics                   g APK                 •   Keep apk „forever“
                          • Run Unit-Tests        •   upload apk to webserver
                          • Run Calabash Tests        for enterprise delivery or
                                                      to Google play
Why did we choose Jenkins
• Quasi-Standart CI Server (together with hudson)
• A lot of useful plugins
   • e.g. Maven Plugin, Checkstyle
      Plugin, Android Lint Plugin,
      Sonar Plugin
• Well documented Plugin API for
  own plugins
Our Jenkins System
                       Jenkins
                       Master




Jenkins      Jenkins             Jenkins   Jenkins
iOS          Android             Windows   Mobile
                                           Web
Automate...
• ...Builds
• ...Unit Testing
• ...Device Tests
• ...Code Coverage & Static Analysis
• ...Deployment
why do we need automated ui-tests?
• Not all parts are covered by classic Unit-Tests
• Manual Integration Tests take a lot of time
• Manual tests are very boring and developers tend to skip
  them
• Device fragmentation grows every day ...
automated UI-Tests with Calabash
• Cucumber based Testing Tool
• Test-Specs are human readable, even for non-programmers
• Both mayor platforms iOS & Android are supported with a identical
  Syntax
• Runs in Simulator/Emulator and on Devices
Example
Feature: Basic Mathematics
  As a user I‘ll be able to do basic mathematic
  operations

  Scenario: Summate 2 numbers
    Given I started the App
    When I press button „5“
    And I press button „+“
    And I press button „3“
    And I press button „=“
    Then label „result“ should be „8“

  Scenario: Substract one number from another
    Given I started the App
    When I press button „9“
    And I press button „-“
    And I press button „4“
    And I press button „=“
    Then label „result“ should be „5“
• All Calabash-Tests run on real Devices, so
  the results are much more reliable
Automate...
• ...Builds
• ...Unit Testing
• ...Device Tests
• ...Code Coverage & Static Analysis
• ...Deployment
Publish Code Analysis Results to Sonar
Automate...
• ...Builds
• ...Unit Testing
• ...Device Tests
• ...Code Coverage & Static Analysis
• ...Deployment
Any questions?
Thank you
           Have a nice day at DroidCon
PS: if you are an StartUp or have a great idea (for mobile) ask me for
              informations on the „adesso mobile fond“

Building High Quality Android Applications

  • 1.
    Building High QualityAndroid Apps By using Jenkins and Automated Device Tests
  • 2.
    Getting to knoweach other... Leif Janzik Team-Lead Android Development adesso mobile solutions GmbH Twitter: @ElliotMonster Blog: www.thoughtsonmobile.com
  • 3.
    About adesso mobilesolutions GmbH • adesso mobile solutions GmbH, Dortmund, 65 MA (Ende 2012) • Tochterunternehmen der adesso AG, Dortmund, ca. 1.100 MA (Ende 2012) • führender Anbieter in den Bereichen mobiles Internet, mobile Applikationen und Mobile Marketing • Portfolio: Beratung, Konzeption, Realisierung, Review, Test und Betrieb von Mobilisierungs-Projekten und App-Lösungen • Kunden: Über 200 realisierten Portalen und Applikationen für Kunden wie Daimler, PAYBACK, ERGO, süddeutsche.de, SportScheck, die Volksbanken Raffeisenbanken, Bundesagentur für Arbeit.
  • 4.
    So you arean Android Developer and everything is f***ing awesome... http://www.flickr.com/photos/fullcodepress/
  • 5.
    Everyone loves yourApps http://www.flickr.com/photos/fullcodepress/
  • 6.
    Your companies headquarter lookslike these http://www.flickr.com/photos/fullcodepress/
  • 7.
  • 8.
  • 9.
    ... time goeson, and the apps evolves, new features, new API-levels, bugfixes etc. http://www.flickr.com/photos/fullcodepress/
  • 10.
    There are „some“new devices ... ... every day http://www.flickr.com/photos/fullcodepress/
  • 11.
    And after someVersions, Refactorings & new Features your Code looks more like this...
  • 12.
    you try tokeep everything fine and running...
  • 13.
    ... but thenumber of bugs continues to grow ...
  • 14.
    maybe your customerswill react like this?
  • 15.
    ... but morelikely they will react like this ...
  • 16.
    ... Your companiesnew headquarter ...
  • 17.
    ... and beinga Android Developer is no fun no more.
  • 18.
    Ok, maybe Iexagerated a bit, BUT • Android Apps grow more and more complex • Customers expect a bugfree and undisturbed App experience • Tolerance even for minor bugs continues to shrink • Device fragmentation makes testing a sisysphean task
  • 19.
    Some „everyday-problems“ wehad to solve • Apps have to be build in many different Versions (e.g. Development/Staging-Enviroment) or different brandings • Developers are often disturbed, e.g. when a AdHoc for the customer is needed • Changes in App Components lead to new bugs, which were discovered later.
  • 20.
    so what isthe solution to this problem?
  • 21.
  • 22.
    but testing yourown app is soooooo boring! (so it might be skipped or not done thoroughly)
  • 23.
    that‘s why weautomated much of our testing and our build process.
  • 24.
    „Our“ solution • a clean and reliable development workflow • a toolchain which supports the developers and keeps disturbing work away • Continuous refactoring of the apps • Maven for lesser configuration for every developer and easier modularisation • Automated Device Tests • Continuous integration
  • 25.
    What is ContinuousIntegration? • Automate everything • Build as often as possible • Build early, build often • e.g. on every commit • or nightly builds
  • 26.
    Benefits of ContinuousIntegration • Fewer Errors • very important, not everybody installs every update, so bugs might never be fixed on a customers device • Fast Feedback • Tests everything on every (nightly) build • Much less manual testing • Cheaper • Happier developers • Regression-Tests without additional effort
  • 27.
    Automate... • ...Builds • ...UnitTesting • ...Device Tests • ...Code Coverage & Static Analysis • ...Deployment
  • 28.
    3 Major BuildProfiles Build after Commit Nightly Build Release or Promoted Build • Build and archive APK • Build Project • Build APK • Run Unit-Tests without • Run Unit-Tests • Run Sonar Code archiving/publishin • Run Calabash Tests Metrics g APK • Keep apk „forever“ • Run Unit-Tests • upload apk to webserver • Run Calabash Tests for enterprise delivery or to Google play
  • 29.
    Why did wechoose Jenkins • Quasi-Standart CI Server (together with hudson) • A lot of useful plugins • e.g. Maven Plugin, Checkstyle Plugin, Android Lint Plugin, Sonar Plugin • Well documented Plugin API for own plugins
  • 30.
    Our Jenkins System Jenkins Master Jenkins Jenkins Jenkins Jenkins iOS Android Windows Mobile Web
  • 31.
    Automate... • ...Builds • ...UnitTesting • ...Device Tests • ...Code Coverage & Static Analysis • ...Deployment
  • 32.
    why do weneed automated ui-tests? • Not all parts are covered by classic Unit-Tests • Manual Integration Tests take a lot of time • Manual tests are very boring and developers tend to skip them • Device fragmentation grows every day ...
  • 33.
    automated UI-Tests withCalabash • Cucumber based Testing Tool • Test-Specs are human readable, even for non-programmers • Both mayor platforms iOS & Android are supported with a identical Syntax • Runs in Simulator/Emulator and on Devices
  • 34.
    Example Feature: Basic Mathematics As a user I‘ll be able to do basic mathematic operations Scenario: Summate 2 numbers Given I started the App When I press button „5“ And I press button „+“ And I press button „3“ And I press button „=“ Then label „result“ should be „8“ Scenario: Substract one number from another Given I started the App When I press button „9“ And I press button „-“ And I press button „4“ And I press button „=“ Then label „result“ should be „5“
  • 35.
    • All Calabash-Testsrun on real Devices, so the results are much more reliable
  • 36.
    Automate... • ...Builds • ...UnitTesting • ...Device Tests • ...Code Coverage & Static Analysis • ...Deployment
  • 37.
    Publish Code AnalysisResults to Sonar
  • 38.
    Automate... • ...Builds • ...UnitTesting • ...Device Tests • ...Code Coverage & Static Analysis • ...Deployment
  • 39.
  • 40.
    Thank you Have a nice day at DroidCon PS: if you are an StartUp or have a great idea (for mobile) ask me for informations on the „adesso mobile fond“