Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Capturing loop count during loop until Fail/Succeed

Options
goofy78270
goofy78270 Posts: 133

I currently use a loop until succeeds loop for some calls to account for backend delays in data propagation, but I am now being asked to capture how many loops it takes (to determine total delay) until the data is propagated.

Is there an internal variable that can be used to capture the current loop count, which I can add as a benign header value or such so that I can see the value in the traffic stream?

Answers

  • benken_parasoft
    benken_parasoft Posts: 1,243 ✭✭✭
    Options

    You could add a test variable to your test suite (Test Variables tab). You could add an Extension tool that gets the value of the variable, increments it, then sets the value back into the test variable again. I found an example in this other post:
    Incremented test variable

  • goofy78270
    goofy78270 Posts: 133
    Options

    Ok, so no internal variable for the loop count. I will setup a variable and extension tool to capture this then.

    Is this possibly something that could be implemented as I would believe there is a counter internally that could be exposed without the use of additional overhead to do the same thing via a variable and script.

  • benken_parasoft
    benken_parasoft Posts: 1,243 ✭✭✭
    Options

    Internally, a counter is used as part of both "While pass/fail" and "While variable" loop types. A counter only exists in this particular case to know whether the number configured for the "Maximum number of loops" has been reached or not. Offhand, this counter appears to be initialized to the "Maximum number of loops" and is decremented each time the loop is run, where the loop will terminate if counter reaches zero and the condition still isn't satisfied.

    There is no public API for accessing the internal counter for a "While variable" or "While pass/fail" condition. You must use your own test variable to count invocations.