Capturing loop count during loop until Fail/Succeed

goofy78270goofy78270 Posts: 107

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?


  • benken_parasoftbenken_parasoft Posts: 957 ✭✭✭

    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

  • goofy78270goofy78270 Posts: 107

    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_parasoftbenken_parasoft Posts: 957 ✭✭✭

    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.

Sign In or Register to comment.