1. 程式人生 > >UiAutomator1.0 與 UiAutomator2.0

UiAutomator1.0 與 UiAutomator2.0

developer clas 之前 logcat -s obj 自動 evel 進行

  在使用2.0之前,對android自動化框架也做過一些了解《Android 自動化測試框架》。使用UiAutomator2.0也有一段時間,這裏將1.0與2.0進行一個對比總結。   UiAutomator1.0:https://stuff.mit.edu/afs/sipb/project/android/docs/tools/help/uiautomator/index.html UiAutomator2.0:https://developer.android.google.cn/topic/libraries/testing-support-library/index.html 技術分享圖片

技術分享圖片

從源碼來看: 2.0基於 Instrumentation, 可以獲取應用Context,可以使用Android服務及接口。 2.0新增UiObject2、Until、By、BySelector等接口。 從使用工具來看:
2.0 使用android studio編寫測試用例。 1.0 使用eclipse 進行編寫。 從執行方式來看: 2.0基於Junit測試運行器,用例無需繼承於任何父類,方法名不限,使用Annotation(註解)進行測試【junit4】。 1.0需要繼承UiAutomatorTestCase類,測試方法名必須以test開頭,【junit3】。 從構建方式來看: 2.0采用Gradle進行構建。 1.0則使用Ant或者Maven構建。 從輸出產物來看: 2.0輸出為Apk,log輸出到logcat中。將.apk文件push、安裝在android設備上運行測試。 1.0輸出為Jar,log輸出到終端控制中。將.jar文件push到設備上運行測試。

UiAutomator1.0 與 UiAutomator2.0