Instruments Automation Tool: Script Ended Without Explicitly Closing This Test
Asked Answered
M

5

1

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");
Mono answered 14/2, 2013 at 0:47 Comment(0)
C
2

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.

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");
}

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.

Calcification answered 14/2, 2013 at 2:1 Comment(2)
Added the else clause but I'm still seeing the same behavior. If I reverse the if/else conditions and use a == test I still see the same behavior. However, if I insert a second innocuous logMessage after the first one then I get the proper pass/fail behavior. I have no idea why that would make a difference but it seems to. Having both if/else condition does make a difference as you mentioned. Going to mark this as answered even though it seems my installation/version is a bit unpredictable.Mono
That's pretty confusing. Have you been experiencing any other oddities in Xcode or other Apple Dev tools? I wonder if something is wrong with your Xcode installation. Your reasoning is correct and I'm confused on why you're experiencing this behavior, too. I can't replicate it on my two dev machines.Calcification
M
1

I found out the real issue here. It is basically saying that your app is not in usable mode to test further at specified point. So please either pass/fail or add appropriate delay at this place.

So easiest solution to avoid this is to have one delay function of 2 sec after each page navigation. That will load data in each page after fetching and displaying data on pano. And script will run smoothly.

//Step:1 Navigating/tapping

UIATarget.localTarget().delay(2);

//verification

//Step: 2 Navigating/tapping

UIATarget.localTarget().delay(2);

//verification

Monoceros answered 14/4, 2014 at 6:19 Comment(0)
P
0

How odd. I'm experiencing this same issue precisely as described above and I am also using the else clause.

Also, I tried the double logging method as mentioned above like so, just before my if statement to log pass or fail:

UIALogger.logMessage("My Story Title: " + titleDisplayed);
UIALogger.logMessage("Innocuous Message.");

And got a FAIL, which is fine--I wanted anything other than the "Issue" result and the "script ended without expliciting" message. So, I then commented // the second logMessage statement and re-ran the test and this time got the "Issue" and "script ended without explicating" again.

So, his above tip has been verified as real.

I'm running Xcode and Instruments version 4.6 with the iPhone Emulator running as a 6.1 project.

---Update--

I cannot get pass/fail to work properly no matter what I do. On one run I get the enraging "Issue: Script ended without explicating " message in my log, and then if I make any changes to the script--even if it's just to add an extra whitespace, and save it and then run again--I'll get a good pass or fail result.

But if I then immediately run the test again without any changes at all I'll get the "Issue: Script ended without explicating" message and this will not go away until I make a meaningless change in the script and save and then run again and then MAYBE at this point I might get a decent pass/fail result (doesn't always happen), but if I run the script again I will get "Issue: Script ended without explicating" again.

What the heck? I've actually taken the time to reinstall Xcode 4.6 but no luck in getting the behavior to change. I'm profoundly frustrated. This appears to be a bug in Instruments. Is there a way to report this to Apple?

Pforzheim answered 6/3, 2013 at 22:44 Comment(0)
W
0

I had this issue too. You have to have the string you put on your logStart method in the logPass or logFail method too - that's all! Which would mean for example:

UIALogger.logStart("Add to Whishlist");
//here comes your automation code
UIALogger.logPass("Add to Whishlist");

You can open then another test with the logStart() and close it either with logPass() methods

Whet answered 10/1, 2014 at 14:26 Comment(0)
R
0

I found out, that if you place delays between the different messages, they actually show up and evaluate the problems. The issue I started with was, that two successive logMessages did not show up correctly (the last one being dropped)

UIALogger.logMessage("This is some text");
UIALogger.logMessage("This is some text");
//UIATarget.localTarget().delay(1);

only showed one output line. Uncommenting shows two... This seems somewhat... inconsistent - and there is more: (This goes to Wulf)

UIALogger.logStart("Add to Whishlist");
UIALogger.logMessage("My Story Title: ");
//UIATarget.localTarget().delay(1);
UIALogger.logMessage("Innocuous Message.");
//UIATarget.localTarget().delay(1);
if (true)
    UIALogger.logPass("Add to Whishlist");
else
    UIALogger.logFail("Add to Whishlist");

Here I got an "issue". Uncommenting helped to solve this. I know, this is no solution. But it worked as a workaround for me.

The "string" in the logStart, logFail or logPass did not matter for me actually.

Reimburse answered 28/1, 2014 at 13:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.