Validation keeps repeating when I don't want it to

Best practices, code snippets for common functionality, examples, and guidelines.
Posts: 20
Joined: Sun Jun 19, 2016 12:23 pm

Validation keeps repeating when I don't want it to

Post by Peter546 » Wed Aug 17, 2016 4:41 pm

Hi there

I have two separate recordings under one test case. In one recording I have a variable that reads in 4 four barcodes from a csv file.

The next recording is supposed to validate the results after all the barcodes have been entered. The problem I am having is that the validation runs every time after each barcode has been entered. I just want it to run once all 4 barcodes have been entered, not after each one.

I have had to create a separate test case for the validation to work around this but is there anyway to do what I want under one test case?

Thanks, Peter

Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Validation keeps repeating when I don't want it to

Post by krstcs » Wed Aug 17, 2016 4:56 pm

Actually, what you already figured out is the correct way to handle it.

Each test case is a for-each loop that loops over each row of data from your data connector. It sounds like your connector has 4 rows (1 for each barcode).

What you should do is move the validation out of the barcode entry test case and into a parent test case, after the barcode test case.

It should look like this:

--TestCaseParent (will run once since there is no data connector)
----TestCaseBarCodeEntry -> Barcode data connector (will run once for EACH row of data in the connector)

Edit: Note that the problem with this setup is that only part of your test is data driven. The validation will have to be set to the specific values, so if the data changes in the future, your validation will fail until you manually change it. My suggestion would be to figure out a better structure for the data/test case so that you can truly data-drive this scenario.
Shortcuts usually aren't...