Skip to content

whysqwhw/Quality-Tools-for-Android

Repository files navigation

Quality Tools for Android

This is an Android sample app + tests that will be used to work on various project to increase the quality of the Android platform.

The idea is that Android programming is still in its infancy compared to the Java world. The Android community needs more robustness in Android apps and it looks like a good idea to build on the Java world experience and use its best tools for Quality Analysis.

We want to provide a full featured industrial development environment that can be used to create more robust projects on Android, by using any of the most interesting and popular technologies.

Already integrated :

  • Standard Android testing framework and code coverage using emma, reported in Sonar. That also covers robotium, easy mock and mockito technologies.
  • Robolectric testing framework and code coverage using Cobertura, reported in Sonar.
  • UI Automator testing through a new android maven plugin goal (to be released in android-maven-plugin-3.5.2) and result in sonar.
  • Configuration works out of the box in eclipse
  • Lint integration via Maven.
  • PMD, findbugs, checkstyle integration via Maven, reported in Sonar.
  • lint android maven lint integration (pom checker)
  • Spoon from square
  • maven-android-sdk-deployer to deliver android jars (including uiautomator)
  • sonar android lint plugin
  • FEST Android.
  • Testing technologies integrated :
    • Standard Android tests
      • easymock
      • mockito
      • mockwebserver
      • robotium
      • fest-android
    • robolectric tests
      • hamcrest
      • easymock
      • mockito

What is missing (TODO/INTEGRATE) :

  1. Using Jacoco instead of emma would help getting more standard Sonar config (has been tested by @godin here), then advertize here.
  2. get aggregated tests and code coverage
  3. get monkey through Maven, using this technique get the results in Sonar
  4. Add support for Travis CI. Alternatives welcome.

Usage

This section describes how to build & test the project using those different testing technologies.

Install Android Latest SDK through Android SDK Manager

This can be done graphically, or via command line (for CI servers).

Install the Android SDK through maven-android-sdk-deployer

As it takes time to get android jars in maven central, including android UI automator jars in maven central, we recommend to use maven-android-sdk-deployer to obtain android artefacts. This step can also be executed on a CI server.

#install Android SDK 17 local files to local maven repo  
git clone [email protected]:mosabua/maven-android-sdk-deployer.git
cd maven-android-sdk-deployer/
mvn install -P 4.2
#Add V4 support library (to use FEST Android)
cd extras/compatibility-v4/
mvn install

Standard Android testing APIs and code coverage using emma

To build the sample project and run the sample app on a plugged rooted device / running emulator :

# in parent folder
mvn clean install -P emma
mvn sonar:sonar -P emma

you will get tests results in : target/surefire-reports/. you will get tests coverage in : target/emma/.

Here is the result in sonar :

You may need to restart adb as root to be able to pull the emma coverage file. In a terminal, type :

adb root

Robolectric and code coverage using cobertura

# in parent folder
mvn clean cobertura:cobertura -P cobertura
mvn sonar:sonar -P cobertura

Here is the result in sonar :

UI Automator

UI Automator tests execution requires Android Maven Plugin version 3.5.2+. It is currently available as a SNAPSHOT on sonatype snapshot repo.

# in parent folder
mvn clean install -P uiautomator
mvn sonar:sonar -P uiautomator

Here is the result in sonar :

Spoon from Squareup

# in parent folder
mvn clean install -P spoon

#then browse to android-sample-tests/target/spoon-output/index.html

Here is the result in a browser :

Robolectric development in eclipse

To enable Robolectric development in this configuration. In eclipse, switch to maven profile "cobertura" in maven settings on the main app.

Thanks to

Quality Tools for Android in the news !!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 82.7%
  • Python 11.4%
  • Shell 5.9%