測試第三方服務
國內
- https://bugly.qq.com/v2/ 騰訊的bugly 免費, 而且相當好用
- 騰訊優測云 提供真機測試和漏洞分析
- Testin
- MTC
- 易測云
國外
- TestCloud
- Testdroid
- Nimbledroid Automated performance analysis website
- Test bird APP和手游測試
第三方性能采集SDK
自動化測試
- CircleCI 一個基于Github的自動化測試,單元測試工具,提供一個免費的私有倉庫。
Google官方學習資料
- Best Practices for Testing 【最新/重點】
-
Android Testing Support library (ATSL) 【重點】
相關視頻: Android Testing (Android Dev Summit 2015) youtube 2015年視頻 - Developer API Testing Concepts
優秀博客
-
Leveraging product flavors in Android Studio for hermetic testing 與之對應的 codelab學習地址
筆記:
- two JUnit Rules @rule will be launched before @Before. The ActivityTestRule is a rule that provides functional testing of a single Activity.
-
Test coverage report for Android application 使用jacoco-android plugin in a build.gradle
進行測試覆蓋率報告
sample - Android單元測試在蘑菇街支付金融部門的實踐 很詳細介紹了單元測試在實踐操作中的使用
RxJava Test**
- Unit Testing RxJava Observables and Subscriptions
- Unit Testing RxJava Observables
- Unit Testing with RxJava
測試框架
Unit Testing
-
Junit4 Github A programmer-oriented testing framework for Java.
http://junit.org/junit4/ - Mockito Tasty mocking framework for unit tests in Java
-
JMockit An automated testing toolkit for Java
對比: mockito不能mock static method和final class、final method,JMockit可以;
對比Mockito和JMockit的文章 - PowerMock 一個可以Mock靜態類的開源庫
Tools for UI Testing: Robotium, Appium, Calabash, Robolectric.
UI Testing
- Espresso Android 官方推薦使用的UI測試庫
- UIAutomator 可以夸應用進行測試
- Robolectric is a unit test framework that de-fangs the Android SDK jar so you can test-drive the development of your Android app. Tests run inside the JVM on your workstation in seconds
More
- RoboSpock Github A testing framework which brings powers of Spock and Groovy to Android app testing http://robospock.org
-
Hamcrest matchers
What is Hamcrest?
Hamcrest is a library of matchers, which can be combined in to create flexible expressions of intent in tests. They've also been used for other purposes.
開源庫
Collection
- awesome-android-testing collection of android test info 【重點】
Sample
- android-gradle-java-template Gradle + Android Studio + Robolectric + Espresso + Mockito + EasyMock/PowerMock + JaCoCo Demo
- Android-Clean-Testing Android Testing Sample Project
- robotium-showcase This example shows how to use Robotium with ActvitityTestRule and @Test annotation, it means in Google's Espresso way.
Google Sample
- android-testing-templates
- android-testing A collection of samples demonstrating different frameworks and techniques for automated testing
Tools 測試工具
square/spoon
在adb devices 檢測到的設備跑測試程序,并提供截屏,文件,數據庫操作:
Screenshots
Files
最最重要的是生成簡單明了的測試報告:
displaying the results in a meaningful way
Android Studio 2.2 Preview new feature:
-
Espresso Test Recorder 菜單/run/Recorder Expresso Test 選項可以記錄你的操作并轉化為Espresso 的測試代碼
-
APK Analyzer 菜單/build/Analyzer APK 提供APK大小分析工具,清楚的知道代碼體積變換的趨勢。
.png
screengrab 當UI Tests 時自動化截屏
STF 遠程控制,一臺電腦控制測試多個測試設
openstf.github.io Control and manage Android devices from your browser

開發時的調試工具
stetho
Facebook開源,很強大的Android網絡和數據庫調試工具,能像調試WebApp一樣調試Android原生應用。借助Stetho在Chrome上調試Android網絡&數據庫
常用配置:
- 初始化
public class MyApplication extends Application {
public void onCreate() {
super.onCreate();
Stetho.initializeWithDefaults(this);
}
}
- Chrome瀏覽器打開
chrome://inspect/#devices
augmented-traffic-control
Fackbook開源項目模擬移動網絡,對App的調試及網絡優化有很大的幫助,主要參數有:
網絡帶寬(bandwidth)
延遲(latency)
丟包率(packet loss)
錯包率(corrupted packets)
亂序率(packets ordering)
GT(隨身調) 騰訊開源的測試套件
能Android設備上安裝,進行移動
調試,確保測試數據的真實有效性
開源地址: https://github.com/TencentOpen/GT
官網地址
使用GT APP進行快速的性能測試(CPU、內存、流量、電量、幀率/流暢度等等)、開發日志的查看、Crash日志查看、網絡數據包的抓取、APP內部參數的調試、真機代碼耗時統計等。
一. 基本功能測試
1. CPU占有率;
2 jiffes(CPU時間片);
3. 內存PSS值穩定在36M;
4. 網絡上行流量和下行流量;
5. "數據存檔"
二. 電量測試
再啟動電流監控觀察,1分鐘后平均電流是220mA
三. crash
- 保存了抓包文件后;
- Logcat查看界面,立即把手機緩存的Logcat日志保存下來;
四. Net
- 系統提供的流量查看也包括局域網socket的流量,而且不能分時段統計;
- tcpdump抓包(需要手機root) + Wiresharek 抓包分析;
疑問點:
1. 激活FPS(幀率)的監測;