引言
- 隨著版本迭代加快翩腐,app復雜度增加逐纬,手工測試無法滿足版本快速迭代需要御雕,需要引入自動化進行回歸測試
- 多分支開發(fā)矢沿,提高打包轉測的質量,打包后自動執(zhí)行一些自動化case酸纲,保障主業(yè)務通暢
基于這兩點原因捣鲸,希望引入[低成本]自動化解決這些問題
airtest框架
是一個跨平臺的、基于圖像識別的UI自動化測試框架闽坡,適用于游戲和App栽惶,支持平臺有Windows、Android和iOS
主流框架對比
appium
airtest
投入產出
傳統(tǒng)級別的移動端UI自動化 id/class/tag疾嗅、des/xpath/pos/text
對比項 | 傳統(tǒng)控件識別 | 圖像識別 |
---|---|---|
原理 | id && 其他 | 圖像 |
腳本編寫成本 | 高 | 低 |
后期維護成本 | 高 | 低 |
入門難度 | 高 | 低 |
跨進程 | 有一定門檻 | 不存在 |
跨平臺 | 成本高 | 零成本 |
成本
- 新功能編寫用例
- 舊功能修改用例
- android/ios的成本
- 執(zhí)行用例
產出
- 功能回歸驗證
- 測試報告
原理
圖像識別
截圖--識別--點擊
for method in ST.CVSTRATEGY:
# get function definition and execute:
func = MATCHING_METHODS.get(method, None)
if func is None:
raise InvalidMatchingMethodError("Undefined method in CVSTRATEGY: '%s', try 'kaze'/'brisk'/'akaze'/'orb'/'surf'/'sift'/'brief' instead." % method)
else:
ret = self._try_match(func, image, screen, threshold=self.threshold, rgb=self.rgb)
if ret:
break
airtest優(yōu)先匹配模板算法外厂,次匹配特征點算法
template_matching
模板匹配
- 無法跨分辨率識別
- 一定有相對最佳的匹配結果
keypoint_matching
特征點的匹配
- 跨分辨率識別
- 不一定有匹配結果
android
- 截圖方式 MINICAP、ADBCAP宪迟、JAVACAP
ios
- 截圖方式 MINICAP酣衷、WDACAP
WebDriverAgent is a WebDriver server implementation for iOS that can be used to remote control iOS devices. It allows you to launch & kill applications, tap & scroll views or confirm view presence on a screen. This makes it a perfect tool for application end-to-end testing or general purpose device automation. It works by linking XCTest.framework and calling Apple's API to execute commands directly on a device. WebDriverAgent is developed and used at Facebook for end-to-end testing and is successfully adopted by Appium.
使用和demo
環(huán)境搭建
直接演示
hello airtest
autocasedemo by android
- 新安裝并打開小火箭app
- 登錄賬號
- 進入進階課星球
- 播放視頻
- 返回首頁
- 退出登錄
二次開發(fā)和CI
適配性
- lbkrunner
codemao運行器,單個.air文件為一條case次泽,多個air集成一個app的casesuit
演示...
- 適配性api
- 數據庫操作
- 測試報告
CI/CD
測試報告
郵件預警