5

每当我尝试在 Apple 的 Instruments(iPhone 模拟器)中进行 UI 自动化时,我都会运行几个不同的脚本。问题是当前一个脚本结束时,我需要坐下来运行每个脚本。我想知道如果我仍然需要一个接一个地坐下来运行每个脚本,那么自动化有什么用。

谁能告诉我(或是否有)一种只需单击一下即可运行多个脚本的方法?并且不需要为每个脚本运行记录按钮?

4

5 回答 5

7

我也有同样的问题。根据官方文档:“您可以创建任意数量的脚本,但一次只能运行一个。”

因此,我尝试通过导入将所有脚本捆绑为一个:

# import "test1.js"
# import "test2.js"

将它保存为一个单独的脚本(例如“testAll.js”)并运行它。

于 2013-08-24T09:27:32.030 回答
4

YES !!! You can run a test suite with all your script. For example you can write a script for each screen in your app, and after created a test suite to run all the script or if you prefer only run a couple of this scripts. You need uses the sentencie #import “script1.js” for each scripts. Example:

//import all scripts that you need to include
#import "screen1.js"
#import "screen2.js"
#import "screen3.js"

function Main(){

// Tests:       
     TestScreen1(); // this method is on "screen1.js"
     TestScreen2(); // this method is on "screen2.js"
     TestScreen3(); // this method is on "screen3.js"

 };

// call to function Main 

Main();
于 2014-08-14T17:37:08.247 回答
3

您可以从命令行运行它们 - 将所有脚本放在一个文件夹中并创建一个 sh 脚本

例子:

FILES=`find <<insert script location>> -iregex '.*\(js\)' `
for script in $FILES
do
    echo "Processing $script

instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate /"<<insert app location>>/App.app" -e UIASCRIPT $script -e UIARESULTSPATH "<<insert Result path>>" >> "results.txt"

done
于 2013-09-16T06:30:36.030 回答
2

您可以从命令行启动仪器,因此您可以使用 bash 脚本以批处理模式运行测试。像这样的东西:

#!/bin/bash    
instruments -t  "$UIA_TRACETEMPLATE_PATH" "$APP_PATH" -e UIASCRIPT "$SCRIPT1_PATH" -e UIARESULTSPATH "$OUTPUT1_PATH"
instruments -t  "$UIA_TRACETEMPLATE_PATH" "$APP_PATH" -e UIASCRIPT "$SCRIPT2_PATH" -e UIARESULTSPATH "$OUTPUT2_PATH"
#etc

这种方法的优点是测试是分开的,因为 bash 脚本会在每次测试之前重新启动仪器。即使是您的第一个测试中止执行将继续下一个测试。

于 2013-09-12T23:45:10.183 回答
1

据我所知,UIAutomation 是一个单进程应用程序,不能并行运行多个测试/设备。

您可以在此处阅读更多信息:仪器自动化跟踪仅允许一个目标连接?

我也尝试在不同的用户下运行自动化,但没有成功。您可以使用虚拟机或多个 mac mini 来完成您的任务。

于 2013-10-01T11:20:27.307 回答