Forum Discussion

atariqnadra's avatar
2 years ago
Solved

Store a series of Id's in a property while iterating in a data source loop

I have a test step within a Data Source Loop that creates test users. Each request to create a user returns the user id in the response. I want  to store all Id's while creating the users so that I can iterate over them one by one later in the test.

  • Hi,

    Have a look at the support material for the datasink step.  This allows you to save data to file.  You can have a datasink step inside the loop of your data-driven test.

    The file produced by the data sink can then be used as the datasource for another loop later in your test.

    If you search this forum, you'll find some other solutions I posted about datasource loops and datasinks.

5 Replies

  • That's funny, I just posted a very similar question. I think the solution is some fancy groovy script that takes the response ID, stores then handles the "later iteration" stuff as well. Curious whether there is a non scripting approach to get this done.

  • ChrisAdams's avatar
    ChrisAdams
    Champion Level 3

    Hi,

    Have a look at the support material for the datasink step.  This allows you to save data to file.  You can have a datasink step inside the loop of your data-driven test.

    The file produced by the data sink can then be used as the datasource for another loop later in your test.

    If you search this forum, you'll find some other solutions I posted about datasource loops and datasinks.

    • atariqharri's avatar
      atariqharri
      Occasional Contributor

      It only stores the value from the latest loop. ChrisAdams 

       

      Edit: your solution works as you explained, thanks!

       

  • ChrisAdams's avatar
    ChrisAdams
    Champion Level 3

    Hi,

     

    That depends entirely on how you set up the datasink step and where you place it.

     

    To capture values from each iteration, the datasink needs to be 'inside' the loop.  I typically place it immediately before the datasource loop so that it is the last step inside the loop.

     

    You can also set-up the datasink such that it overwrites or appends data.  Overwrite means that when the test starts, the datasink is emptied.  Append will just keep on throwing data into your file.  For your needs, I'd suggest overwrite.

     

    If you're still having issues, then some screenshots of your test would be useful.