繁体   English   中英

如何在ios中停止自动化测试

[英]How to Stop the automation testing in ios

有没有办法阻止自动化测试? 实际上即时通过自动化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;
    }
}

作为一个功能,你可以包装你的测试。如你所见,它将开始测试,完成测试的步骤(如果可能)。 如果失败,测试将记录元素树(非常方便),然后再次抛出相同的错误,停止测试继续,并提供有关您遇到的错误的信息。

我强烈建议使用tuneup_js来运行UIAutomation 如果一个测试使用Instruments GUI失败,我认为你不能停止测试运​​行,但是当使用tuneup_js库并tuneup_js运行测试时它会停止

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM