While loop using a datasource value

I am creating tests for a rest API. I need to figure out how to have a Test Scenario loop x number of times where x is a value from a previous GET and stored in a writable datasource using a databank. Basically, what I would like to do is the following:

  1. GET number of widgets, store this number (in a writeable DataSource as numWidgets?)
  2. Loop until numWidgets == 0
    2.1 POST command
    2.2 numWidgest = numWidgets - 1, store this number

Any thoughts?

Thanks

Comments

  • benken_parasoftbenken_parasoft Posts: 461 ✭✭✭
    edited September 2017

    High level . . .

    1.) You would set a test suite variable to the number of widgets. You would do this using a Data Bank tool with an extraction that would be running an XPath that returns the widget count.

    2.) You have a separate test suite that would loop using the test logic variable that you set with your Data Bank. The test suite's "Execution Options> Test Flow Logic" tab has options to configure a while loop. In that section, you would configure "loop until" your test variable is 0 and configure the "do" field to decrement the variable.

    The SOAtest User's Guide has detail about configuring test flow logic and variables.

    Alternatively, if there are more values that you need to extract aside form the widget count, like specific values for each widget, then you wouldn't use a test variable. Instead, your Data Bank would be extracting values for each widget to a Writable Data Source and the subsequent suite would be simply iterating over the Writable Data Source.

Sign In or Register to comment.