原文:https://github.com/stephanenicolas/Quality-Tools-for-Android

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.

Here are some slides to present Quality Tools for Android.

Already integrated :(THEIRS>准备集成)

  • 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. Now in same eclipse project / maven module as app under test thanks to this thread.
  • 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)
  • Monkey testing is now automated and reported in Sonar.
  • Add classycle support, to enforce architectural constraints, through classycle maven plugin
  • Spoon from square, including screenshots during tests. *
  • maven-android-sdk-deployer to deliver android jars (including uiautomator)
  • sonar android lint plugin
  • FEST Android.
  • Jacoco offline instrumentation for both robolectric and standard junit tests.
  • Testing technologies integrated :
    • Standard Android tests

      • easymock
      • mockito
      • mockwebserver
      • robotium
      • fest-android
    • robolectric tests
      • hamcrest ->junit
      • easymock
      • mockito
    • calabash
  • Screenshot lib works during UIAutomator tests.
  • support for Travis CI.
  • Build Status on Travis: 

What is missing (TODO/INTEGRATE) :(ME>得到了什么?)

  1. get aggregated tests and code coverage for all testing technologies inside a nice Sonar dashboard for Android.
  2. add support for monkey runner through maven
  3. add calabash support.
  4. Add support for JUnit 4 on Android : http://stackoverflow.com/questions/9809180/why-is-junit-4-on-android-not-working

Usage(HOW TO DO IT?>如何做到?)

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

Please note that this project is under active development. Some goals may require a snapshot version of the maven android plugin available on sonatype snapshot repo.

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 git@github.com: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 : 

Unified code coverage for both Robolectric and standard Android Junit tests via Jacoco(Java Code Coverage)

Using offline instrumentation of Jacoco, it is possilbe to completly replace emma by jacoco for instrumentation. This allows to get both robolectric and standard tests code coverage inside the same project dashboard with sonar.

  • Robolectric are considered standard unit tests.
  • standard Android Junit tests are considered as standard integration tests. This makes sense as Robolectric tests mock an android platform and can be considered more "unit" tests thant standard android tests because the latter needs a real android platform and relies on networking, disk, locale, etc. It would be better to be able to give names to the test suites inside the widget, and even to add more test suites, for instance to add UI testing (black box testing) or monkey testing.
# in parent folder
mvn clean install -P jacoco
mvn sonar:sonar -P jacoco

Here is the result in sonar : 

UI Automator

# 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 : 

Monkey testing

Monkey is part of Android SDK and allows to harness Application UI and test their robustness. We contributed to a neww maven android plugin goal to use monkey automatically and get reports in junit format.

The results can be displayed inside sonar and will appear as normal unit tests.

# in parent folder
mvn clean compile -P monkey
mvn sonar:sonar -P monkey

Here is the result in sonar : 

Package cycles check via classycle

You will need a JDK 1.7 for this profile to work correctly.

# in parent folder
mvn clean compile -P cycle

Will check package cycles (also called package tangling in Sonar) and check the build if given cycles are detected.Classycle lets you define architectural constraints that can be checked automatically.

Depedency definition files are very simple to edit. Here is an example :

show allResults###define packages / groups of packages of interest## layers
[ui] = com.octo.android.sample.ui.*
[other] = com.octo.android.sample.* excluding [ui]###check layers integrity
check [other] independentOf [ui]

Robolectric development in eclipse

RoboElectric tests are now fully integrated to the sample project. They are placed under src/test/java as in any normal Java project.

To make this configuration work in eclipse, do the following :

  • after each "maven update" of your project, remember to configure the build path of your project, go to the last tab anduncheck maven dependencies so that they are not included into the final apk.
  • in your eclipse junit configuration for your project, add both "bin/classes" to the classpath, and set the environment variable ANDROID_HOME to the android home folder on your computer.
  • add the android jars from your maven repository to your junit run configuration in eclipse.

TODO : POST a SNAPSHOT of the JUnit run config in eclipse

Now, simply execute your project as a JUnit project and all robolectric tests will get executed.

Using Gradle

Our first attempt to use gradle lets you build the sample app :

With Gradle 1.6+ :

# in parent folder
cd android-sample
gradle aD

Thanks to

  • OCTO Technology to provide us with free time to work on that project.
  • Henri Treblay from OCTO Technology for having ported EasyMock to Android.
  • Thanks to Jayway for their Android Maven Plugin.
  • Thanks to Sonar Source for supporting this effort, especially for this project's configuration.
  • Thanks to Jake Wharton and Pierre-Yves Ricaud for mentionning FEST-Android.

Quality Tools for Android in the news !!

  • Android Weekly issue #55 !
  • Android Dev Weekly, issue #49 !
  • Our presentation at Devoxx France 2013.

Quality Tools for Android相关推荐

  1. Suggestion: add 'tools:replace=android:value' to meta-data element at AndroidManifest.xml:25:5-2...

    记录下来少走些坑吧 一:不管用 tools:replace="android:icon,android:theme" xmlns:tools="http://schema ...

  2. android tools ignore,android tools属性引用

    利用tools命名空间,android studio支持很多XML属性,当构建app时这些属性会被擦除,对APK的大小和运行时行为没有任何影响.请看官网. tools属性大致可以分为三类:1,错误处理 ...

  3. Manifest merger failed问题:tools:replace=android:theme和tools:replace=android:icon

    Error:Execution failed for task ':app:processDebugManifest'. Manifest merger failed : Attribute acti ...

  4. 下载Android SDK tools完成Android SDK 安装、配置环境变量

    Table of Contents 一.下载Android SDK tools 二.安装 三.配置变量 四.验证环境变量 开发Android程序必需有Android SDK(Software Deve ...

  5. Suggestion: add 'tools:replace=android:authorities'解决

    出现的原因是在项目A中依赖了xiag项目B,他们又有相同的字段,因此出现命名冲突.. 解决办法: 在AndroidManifest.xml 的 application 下添加命名空间: xmlns:t ...

  6. AndroidStudio出现tools:replace=android: authorities,tools:replace=android:resource

    在做项目的时候需要导入第三方库时碰到这个问题: Error:Execution failed for task ':app:processDebugManifest'. > Manifest m ...

  7. android tools ignore,android 中tools:ignore=UselessParent这个属性的含义是什么?

    满意答案 zjpx456 2018.03.05 采纳率:53%    等级:12 已帮助:7021人 这个属性是给lint检查工具看的,这个告诉IDE 以避免显示这样一条消息: "此 Rel ...

  8. 解决android sdk中找不到tools目录Android sdkmanager tool not found (D:\Android\SDK\tools\bin\sdkmanager).

    安装flutter时,使用flutter doctor报错: Android license status unknown. Try re-installing or updating your An ...

  9. Manifest merger failed Suggestion: add 'tools:replace=“Android:value”' to meta-data element at And

    Attribute meta-data#Android.support.VERSION@value value=(25.3.1) from [com.android.support:appcompat ...

最新文章

  1. 楚留香手游系统互通的服务器,楚留香手游互通服务器汇总 哪些服能一起玩
  2. 隐形需求 软件测试,从开发角度聊聊如何洞悉隐性需求
  3. python之os模块
  4. java web 线程_多线程在javaweb中的应用
  5. c iostream.源码_通达信指标公式源码精准买卖主图指标公式免费分享
  6. swift 3.0 中使用 xib
  7. python变量的使用_python – 如何在变量中使用冒号(:)
  8. 工作资讯002---FaaS和PaaS的关系_Iaas_Paas_Saas
  9. 12. 程序扩展性(高级特性)
  10. 让程序员爱不释手的两个导航网站
  11. Oracle建表规范
  12. 爬取虾米音乐flac高品质下载
  13. 大概的知识点 有点乱(乱的一批)
  14. Android 架构组件之 Room
  15. TextView 跑马灯效果
  16. 加密就像玩魔方----图文详解对称加密(DES、AES)
  17. 【H5/JS】游戏常用算法-碰撞检测-包围盒检测算法(2)-矩形
  18. 统计输入字符串中大写字母、小写字母、阿拉伯数字个数和特殊符号的个数
  19. 抄底绝招:底部大阳!
  20. 计算机桌面没有cd驱动器,电脑没有光盘驱动器怎么解决?

热门文章

  1. 运动APP软件开发具有什么好处?
  2. CDISC SDTM HO domain学习笔记
  3. 电压比较器电路,当两个输入端全是相同电平时,输出什么电平?则相当于差模输入电压为零,不考虑失调或共模输出就应该输出为0
  4. 【独行秀才】macOS Big Sur 11.5 正式版(20G71)原版镜像
  5. CSP-J2022复赛
  6. 艾永亮:超级产品战略告诉你,怎样才能吸引到用户使用你的产品
  7. html5视频教程华清,华清创客学院—HTML5是否能代替Flash
  8. 二度云抢先成为首批工信部(.vip/.xyz/.club)域名注册管理机构
  9. 标准化API设计的重要性
  10. python中average什么意思_在Python3 numpy中mean和average的区别详解