星屿浅奈 ✧ Saneko

Back

Android配置uiautomatorBlur image

添加依赖#

在build.gradle中添加uiautomator依赖

androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
bash

添加依赖

编写用例#

需要在androidTest中编写用例,而不是在main中。新建一个test类,下面是一个打开设置的一个测试。

安装APK#

需要安装2个apk,一个是由main中编译出来的apk(傀儡应用),另一个则是由androidTest编译出来的apk。可以直接通过右侧的Gradle中的install直接安装。

安装APK

运行测试#

打开命令提示符,输入以下指令即可开始进行测试

adb shell am instrument -w -e class com.tt.demo.test#openSettings com.tt.demo.test/androidx.test.runner.AndroidJUnitRunner
bash

instrument参数 🌊

Android配置uiautomator
https://saneko.me/blog/cabc72eceae5
Author Saneko
Published at January 13, 2025
Buy me a cup of coffee ☕.
Comment seems to stuck. Try to refresh?✨