有什么方法可以停止自动化测试吗?实际上,我正在使用自动化 javascript 测试我的应用程序。我的脚本中有两个测试。如果第一次测试失败我不想继续我的脚本.. 我的代码:
var target = UIATarget.localTarget();
var testname = "Test1";
UIALogger.logStart(testname);
target.frontMostApp().mainWindow().buttons()[0].tap();
UIALogger.logPass(testname);
target.delay(2);
var testname = "Test2";
UIALogger.logStart(testname);
target.frontMostApp().mainWindow().buttons()[1].tap();
target.frontMostApp().mainWindow().buttons()[0].tap();
UIALogger.logPass(testname);
在这里,如果 test1 失败,我必须说出停止进程的脚本。请告诉我对这个问题的任何建议。谢谢...
最佳答案
你真的应该考虑抽象出你的测试。你可以使用类似的东西:
function test(description, steps) {
try{
UIALogger.logStart(description);
steps();
UIALogger.logPass("Test Passed");
} catch (exception) {
UIALogger.logError(exception.message);
UIATarget.localTarget().logElementTree();
UIALogger.logFail("Test Failed");
throw exception;
}
}
作为一个函数,您可以将测试包装在其中。如您所见,它将启动测试,完成测试的步骤(如果可能)。如果失败,测试将记录元素树(非常方便),然后再次抛出相同的错误,停止测试继续,并提供有关您遇到的错误的信息。
关于javascript - 如何停止 ios 中的自动化测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14998421/