After calling KeywordTests.TestName.Run via a script, is there any way to stop execution of the keyword test and continue through the remainder of the script?
Calling Runner.Stop(True) just ends the entire process, I am hoping for a way to have the runner continue stepping through the remaining code
Within the Keyword test, there is a "Stop Execution" operation that you can add in to halt the execution of the keyword test. I'm assuming that you want to have a condition in the keyword test that, if the condition fails, that you halt the execution. I'd use that "Stop Execution" operation for that.
That gives the same functionality as if Runner.Stop were called in my error event script, which isn't what I'm needing.
I'm calling multiple keyword tests to run via a script, and I'm trying to think of a way to write it out so that if an error occurs during the execution of a keyword test, it stops trying to run the keyword test and then continues on to the next line of code in the script.
Being able to simply put in my code something like "KeywordTests.TestName.Stop" would be simplest way to go about it, but that isn't valid code. (At least not for VBscript)
You are correct, I just tried it. The "true" parameter for stopping a current test item stops because running the script is a "test item".
OK, there is something else to look at as well.
Go to Tools | Current Project Properties | Playback and check what the setting is for "On error" in the Error Handling section.
Additionally, something to try is to use exception handling in your keyword test to control the halting of the test. Use "try/catch/finally" to control test control flow.
Yeah that setting is set to False (most of those are). I'm currently in TestComplete 12.
Are Try/Catch/Finally valid operators in VBscript? I was under the impression that they were not. Although that would probably be the easiest option to catch the error if I could just do
But I was under the impression that those were not valid operations for VBscript.
Or are you talking about enclosing the actions of the keyword test itself in a Try/Catch using the TestComplete Methods?
Actually, what I meant was using try/catch/finally in the keyword tests themselves. Build into the tests exception handling and such that they can cleanly exit out when desired so that your script code can continue.
I've recently been looking into doing something quite similar. In some cases I find one KWT is a prerequisite for the next, but just because KWT 1 failed, doesn't mean I can't run KWT 3 - I just want to skip over KWT 2
The approach I'm using is to always have my KWTs themselves return a true/false
The entrie KWT is in a Try/Catch/Finally structure.
If it falls through to the catch, you will obviously return false
If it reaches finally you will have to figure out if you want to return a true or a false. Sometimes I use a KWT level boolean variable and if, say halfway through my KWT an object recognition fails, the variable is set to false and I insert a Go To Label. The Finally block can then return the value of the global variable.
When you call the KWT from a script, you should now be able to assign the output of the KWT.Run() to a variable.
var kw1tpassed = KWT1.Run();
Log.Warning("KWT1 failed. Check your logs");