I've been beating my brains out on this issue for the last week and have nowhere else to turn. Currently, whenever I run tests in Instruments the pass/fail logging feature almost always reports:
Issue: Script ended without explicting closing this test
NOTE -- yes, the spelling error is correct
But my logging method is correct. And sometimes when I make a change to the test, perhaps just adding an extra whitespace or maybe a comment, then save and run again, the pass/fail functionality will actually work ONCE!
But then if the same code is immediately run again without any changes, the Issue: Script ended without explicting closing this test
issue occurs again.
It's maddening!
Here's an abridged example of my test code:
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
As stated previously, when this code is run I get:
Issue: Script ended without explicating closing this test
But If I add a second logMessage()
method, or make any changes to the script--even adding a comment, and save these changes and then run again--there's an 80% chance that pass/fail will work for a single run. But if the code is then immediately run again with no changes, then the enraging "Issue: Script ended...
" behavior occurs again.
I'm at wits end here. Any help or feedback would be most appreciated!
Also, this same problem has been experienced by others as reported here: Instruments Automation Tool: Script Ended Without Explicitly Closing This Test
---------------------UPDATE----------------------------
I've now duplicated the issue on a separate MacBook Pro running Xcode 4.6. I've also made various efforts to intentionally fail my tests--just to get a reaction, but still get the Issue: Script ended without expliciting closing this test
log message, which tells me the conditionals might not even be getting read. Yet, again, if I make any minor changes to the script and then save these changes and run again, there's a good chance that the pass/fail function will work for a single run, then start having the "Issue: Script ended..." behavior again on the very next run even with no script changes.
---------------------UPDATE x 2----------------------------
It's the IF statement that appears to be non firing and I can't even use a breakpoint to verify this for sure. But I just ran a simple test like this:
UIALogger.logStart();
if (5 < 10)
{
//Mark the test as a PASS
UIALogger.logPass();
}
else
{
//Mark the test as a FAIL
UIALogger.logFail();
}
And still got Issue: Script ended without explicating closing this test
---------------------UPDATE x 3----------------------------
So, I just created a whole new separate script in Instruments with ONLY the code below, and now pass/fail always works no matter how I change the relative values in the IF
statement. Wow, this is getting stranger by the moment.
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();
}