gradle
checkstyle
官网: http://checkstyle.sourceforge.net
Checkstyle 它定义了一系列可用的模块,每一个模块提供了严格程度(强制的,可选的…)可配置的检查规则。规则可以触发通知(notification),警告(warning)和错误(error)。
findbugs
官网: http://findbugs.sourceforge.net
FindBugs 它是一个基于静态规则集的Java字节码分析器(所以你至少需要编译一次代码,然后才能够测试它)。它能检测到java程序中常见的错误。
pmd
官网: http://pmd.sourceforge.net/pmd-5.1.1/howtomakearuleset.html
Pmd 它是一个基于静态规则集的Java源码分析器,工作有点类似Findbugs,但是(PMD)直接检查源代码而不是检查字节码。
它可以识别出潜在的如下问题:
- 可能的bug——空的try/catch/finally/switch块。
- 无用代码(Dead code):无用的本地变量,方法参数和私有方法。
- 空的if/while语句。
- 过度复杂的表达式——不必要的if语句,本来可以用while循环但是却用了for循环。
- 可优化的代码:浪费性能的String/StringBuffer的使用。
lint
官网: http://tools.android.com/tips/lint-checks
android lint相关的源码:
Android-Lint 检查问题列表: lint –show or lint –list
android lintOptions 选项配置:
example: http://avatarqing.github.io/Gradle-Plugin-User-Guide-Chinese-Verision/testing/lint_supportlint.html
在gradle中忽略掉lint task
tasks.whenTaskAdded { task ->
if (task.name.equals("lint")) {
task.enabled = false
}
}
Android 自动化测试
Android 测试教程:
http://wiki.jikexueyuan.com/project/android-test-course/test-foundation.html
Android Testing Options :
https://github.com/codepath/android_guides/wiki/Android-Testing-Options
知乎:种类介绍 http://www.zhihu.com/question/19716849
Developing Android unit and instrumentation tests - Tutorial
http://www.vogella.com/tutorials/AndroidTesting/article.html
Android 测试原则:
70-80 % unit tests to ensure stability of your code basis
20-30 % functional tests to ensure that the application really works
some cross functional tests if your application integrates intensively with other Application components
参考:
How to improve quality and syntax of your Android code
http://vincentbrison.com/2014/07/19/how-to-improve-quality-and-syntax-of-your-android-code/gradle func for checkstyle:
https://docs.gradle.org/current/dsl/org.gradle.api.plugins.quality.Checkstyle.htmlgoogle java style
http://checkstyle.sourceforge.net/reports/google-java-style.html