gpt4 book ai didi

android - 通过 Android 应用程序运行 UiAutomator 测试

转载 作者:行者123 更新时间:2023-11-30 03:16:18 26 4
gpt4 key购买 nike

我构建了一些测试,但我的测试部门不知道如何使用终端。 Uiautomator 测试是 .jar 文件,因此必须通过终端运行。因此,为了方便起见,我想为他们制作一个应用程序,其中包含列表中的测试以供选择执行。这可能吗?我的研究使我相信这些设备将需要 Root 。如果是这样的话,我将无法做到。那么有解决方法吗?这是我尝试过的:

  Runtime rt = Runtime.getRuntime();
try {
Process process = rt.exec("su");
DataOutputStream os = new DataOutputStream(process.getOutputStream());

os.writeBytes("uiautomator runtest test.jar -c ui.test.getData\n");
os.flush();

os.writeBytes("exit\n");
os.flush();
process.waitFor();

} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}

这段代码会产生这个:

  java.io.IOException: Error running exec(). Command: [su] Working Directory: null Environment: null

请帮我想办法让它工作。谢谢!

最佳答案

Do you have suggestions of something I could do to make it easy for my testing team to run a test of mine?

创建一个运行测试的桌面应用。

或者,只需在它前面放一个漂亮的批处理文件/shell 脚本。可能会启动测试并在测试人员的 Web 浏览器中显示一张可爱小猫的照片。

(测试人员喜欢可爱的小猫)

或者,设置一个持续集成服务器,这样测试人员就根本不用手动运行测试——测试是自动运行的,测试人员只是检查结果。我假设有人有 Hudson/Jenkins/任何可以运行 uiautomator 测试的方法。并且可能有一个单独的方法用于将可爱小猫的照片整合到测试结果报告中,尽管您可能会为此编写自己的代码。

关于android - 通过 Android 应用程序运行 UiAutomator 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20053390/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com