Forum Discussion

pharossupport's avatar
13 years ago

Conditional GoTo step with timeout

We're struggling on a particular problem, and hopefully there's another way to tackle this or a solution that we haven't thought of.

We have a service call, where we receive a response immediately from the service, and then we need to wait a few seconds for the system to do some processing, and then check the result. The processing can take a variable amount of time. The simple solution is a delay, which is not guaranteed since it can take a few seconds for processing to happen, and we don't want to wait x seconds for every test.

The second solution is using a conditional go-to step to wait for the "result" to appear, and then have the last step check that result, which works well. Unfortunately in the rare case where processing has gone wrong, we can expect to be waiting "forever" for the result to happen, causing the test to hang indefinitely.

We would like to add a timeout to this step, so that if it takes too long, we can fail the test. Unfortunately it seems that this isn't an option, nor can we find a way to add a timeout to TestRunner either. Also if there is a bug causing the result to not happen, it means the entire suite will hang and we would need to fix the specific bug before getting results on the entire test suite.

1 Reply

  • Delicate problem you got there

    This is my take to solve it. Create a Groovy TestStep after the Delay step with the following code:
    if( context.triesLeft  )
    {
    log.info context.triesLeft
    if( --context.triesLeft == 0 )
    {
    testRunner.fail( 'Giving up...' )
    }
    } else
    {
    context.triesLeft = 5 // this is the number of tries that you want to allow
    }


    Regards

    Henrik
    SmartBear Software