Auto increment value into CSV

I have a test using the test data from CSV file. It takes the value ‘00123’ for variable ‘form_number’ and once test ran successfully I need to update the value into csv as ‘000124’ for the next run.

It should be incremented every time when the test runs.

1 Like

you should be able to use groovy/java to update file.
with that said, you should never relay on leaving/storing anything between executions anywhere outside of test.
if you need identifier to distinguish test runs use e.g. timestamp.
issue with storing data is that some tests may fail unexpectedly and you can be left with data that are not representing truth (e.g. something will exist with that id and then test will fail due to that reason)

I also need this functionality in there as well and I was going to look at possibly storing the value in a dataset (yet to do). Originally wondering if we can increment a global variable but don’t think we can do that (?)

For my usage, it’s not about having an identifiable number per say, it’s about just incrementing in each test run - for example, I have a 6 digit “package_number” field, so rather than using random number I want to start at 1 then just increment in each run of the test so it’s guaranteed to be unique (at least until we have done 999999 tests :wink:

for storing things there are librarieries that are working with csv files … e.g.

just reminder - all is good if YOU are the one and only one running tests.
with 2 people - you need to figure-out locking of file etc.
and using such test from CI/CD pipeline is another beast on it’s own…

1 Like