仪器自动化工具:在没有明确关闭此测试的情况下结束脚本 [英] Instruments Automation Tool: Script Ended Without Explicitly Closing This Test

查看:86
本文介绍了仪器自动化工具:在没有明确关闭此测试的情况下结束脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我今天在使用仪器中的自动化工具,但在编写工作测试时遇到了问题。以下示例将以问题退出:问题已结束但未明确关闭此测试。是的,该消息确实说明了明确。我认为这是最近版本的Xcode中引入的拼写错误。这是我第一次尝试使用这个工具。将 cellCount 设置为6会产生一个Pass,但是任何东西都会给我'script ended'消息。我做错了还是自动化工具有错误。

I was playing around with the Automation tool in Instruments today but have had problems writing a working test. The following example will exit with Issue: Script ended without explicting closing this test. Yes, the message really does say expliciting. I assume this is a typo introduced in a recent version of Xcode. This is the first time I've tried using this tool. Setting cellCount to 6 results in a Pass but anything gives me the 'script ended' message. Am I doing it wrong or is there a bug with the Automation Tool.

UIALogger.logStart("Start Simple Test");
var target = UIATarget.localTarget();
var cellCount = 7;

UIALogger.logMessage("cell count: " + cellCount);

if (cellCount != 6) {
    UIALogger.logFail("Failed");
}

UIALogger.logPass("Passed");


推荐答案

我认为发生的事情是关闭日志组不正确。当你说 logStart()时,你开始使用乐器中的日志组以及之后用 logMessage()记录的所有内容或 logError()将包含在该组中。

I think what's happening is you are closing your log group incorrectly. When you say logStart(), you begin a log group in instruments and everything you log after that with logMessage() or logError() will be enclosed in that group.

您使用关闭组logFail() logPass()它看起来像你试图做的,但你只能调用其中一个。你需要一个else子句来调用 logPass(),如下所示:

You close groups with either logFail() or logPass() which it looks like you tried to do, but you can only call one or the other. You need an else clause in there to call logPass() like so:

if (cellCount != 6) {
    UIALogger.logFail("Failed");
} else {
    UIALogger.logPass("Passed");
}

奇怪的是,当我将你的代码片段粘贴到UI Automation中时,我没有得到你提到的问题错误。它只是将两个日志组打印到跟踪日志中。尝试使用像我上面提到的else子句,看看它是否有效。

Strangely, when I pasted your code snippet into UI Automation, I didn't get the issue error you mentioned. It just printed two log groups to the trace log. Try using the else clause like I mentioned above and see if it works.

这篇关于仪器自动化工具:在没有明确关闭此测试的情况下结束脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆