Forum Discussion

Ag3nt49's avatar
Ag3nt49
Occasional Contributor
6 years ago

stopping execution of a keyword test in script

Hello,

 

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

  • 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.  

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    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.

    • Ag3nt49's avatar
      Ag3nt49
      Occasional Contributor

      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)

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        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.