Forum Discussion

JimmyProfit's avatar
JimmyProfit
New Contributor
14 years ago

Loop TestCase continuously

Hi,

Is it possible to activate the option « Loop TestCase continuously » with a groovy script, and/or by setting a property, and/or from the command line ?

Thanks
  • Hi,

    Yes it can be achieved using Groovy.
    Hint : Use a temp boolean variable "loop" (testcase level property) and based on the value 'true' of the same iterate the testcase continously. When you want to jump out of the loop, change the value to 'false'.

    Refer my blog at http://pradeepbishnoi.blogspot.com to get the groovy snippet to iterate through the teststeps/testcase and modify as per your needs.

    I hope this will help!
    ~~ Pradeep Bishnoi ~~
  • Finan's avatar
    Finan
    Frequent Contributor
    To answer the other question, (AFAIK) there is no method in the API to access the "continuous loop" button on testcase level.
    So you are best off with creating your own method/logic to achieve this.
    I take it that you want to stop the loop if the testcase fails?

    There are a few different tactics for this:
    1. Easiest would be to add a groovy script at the end of the testCase and add as code: testRunner.gotoStepByName("testStep1Name")
    2. Other tactic would be the script from pradeep.