【发布时间】:2013-02-24 09:29:27
【问题描述】:
上周我一直在这个问题上绞尽脑汁,无处可去。目前,每当我在 Instruments 中运行测试时,通过/失败日志记录功能几乎总是会报告:
问题:脚本结束时没有明确关闭此测试
注意——是的,拼写错误是正确的
但是我的记录方法是正确的。有时当我对测试进行更改时,可能只是添加一个额外的空格或注释,然后保存并再次运行,通过/失败功能实际上会工作一次!
但是如果相同的代码立即再次运行而不做任何更改,Issue: Script ended without explicting closing this test 问题就会再次出现。
这太疯狂了!
这是我的测试代码的一个节略示例:
var target = UIATarget.localTarget();
var app = UIATarget.localTarget().frontMostApp();
var testName = "LoginCreateEntry";
//Start test logging
UIALogger.logStart(testName);
//**Do UI automation stuff here generated by Instruments/record**
//The automation creates a list entry in my application
//The flow goes, run the automation that creates the entry, then verify that the entry
//got created as expected and is visible to the user in the iPhone interface.
var window = app.mainWindow();
var tableView = window.tableViews()[0];
var tableGroup = tableView.groups()[0];
var entryName = "My Dogs!";
var myEntry = tableView.cells()[0].name();
//Do a bunch of UI automation here to create my entry, which results in the entry
//appearing in the mainWindow with the label: My Dogs!
//Get the value held in myEntry to print to the log so that I know
//the variable has a value in it to evaluate
UIALogger.logMessage("My Story Title: " + myEntry);
//If myEntry evaluates to true, then call this test a pass.
if (myEntry === entryName) {
UIALogger.logMessage("My entry was created!");
//Mark the test as a PASS
UIALogger.logPass(testName);
}
else {
UIALogger.logMessage("My entry was not created!");
//Mark the test as a FAIL
UIALogger.logFail(testName);
}
//End test
如前所述,运行此代码时,我得到:
问题:脚本结束时没有说明关闭此测试
但是,如果我添加第二个 logMessage() 方法,或对脚本进行任何更改——甚至添加评论,并保存这些更改然后再次运行——通过/失败的可能性为 80%一次运行。但如果代码立即再次运行而不做任何更改,那么令人愤怒的“Issue: Script ended...”行为就会再次发生。
我在这里束手无策。任何帮助或反馈将不胜感激!
此外,这里报告的其他人也遇到过同样的问题:Instruments Automation Tool: Script Ended Without Explicitly Closing This Test
----------更新-------------- ---
我现在已经在运行 Xcode 4.6 的单独 MacBook Pro 上复制了这个问题。我也做了各种努力故意让我的测试失败——只是为了得到一个反应,但仍然得到Issue: Script ended without expliciting closing this test日志消息,它告诉我条件可能甚至没有被阅读。然而,再一次,如果我对脚本进行任何微小的更改,然后保存这些更改并再次运行,则通过/失败功能很有可能会在一次运行中起作用,然后开始出现“问题:脚本结束.. ." 的行为在下一次运行时再次出现,即使没有更改脚本。
----------更新 x 2---------- -----
这是似乎没有触发的 IF 语句,我什至不能使用断点来确定这一点。但我只是运行了一个这样的简单测试:
UIALogger.logStart();
if (5 < 10)
{
//Mark the test as a PASS
UIALogger.logPass();
}
else
{
//Mark the test as a FAIL
UIALogger.logFail();
}
仍然得到Issue: Script ended without explicating closing this test
----------更新 x 3---------- -----
所以,我刚刚在 Instruments 中创建了一个全新的单独脚本,仅使用下面的代码,现在无论我如何更改 IF 语句中的相对值,通过/失败始终有效。哇,现在越来越陌生了。
var target = UIATarget.localTarget();
UIALogger.logStart();
if (5 > 10)
{
//Mark the test as a PASS
UIALogger.logPass();
}
else
{
//Mark the test as a FAIL
UIALogger.logFail();
}
【问题讨论】:
标签: ios instruments ui-automation