Ask a Question

Data driven testing: automatically update from - to records values over testruns

mgroen2
Super Contributor

Data driven testing: automatically update from - to records values over testruns

I use Data Driven loops for my tests (reading the values from Excel).

 

Currently, prior to each new test run, I need to update the From value, to the value last + 1. Reason: each entry needs to be unique in our application.

 

I need something to do this automically (don't want to be busy setting from values).

 

Example scenario:

first execution run: records 1 to 10

 

Prior to the next test run, I need to set the From record value to 11.

 

Is there a way to implement this?

2017-01-05_10-28-28.png

 

 

 

7 REPLIES 7
baxatob
Community Hero

Re: Data driven testing: automatically update from - to records values over testruns

From the first glance you can consequentially use a several number of similar data-driven loops:

 

ddt.png

mgroen2
Super Contributor

Re: Data driven testing: automatically update from - to records values over testruns

@baxatobYes, but this doesn't not auto update from value (where to start up) over test executions, right?

 

Once again, I need tooling that automatically starts from next record in the sheet, where next is defined as {last used test data line + 1). I need this to be traced persistant so even when TC / computer shuts down, this setup remains working.

 

Consider this scenario:

 

I have one 1 big test data file, containing 100000 entries (lets say customer entry data). Each nightly test execution, I use 5 of these 100000 for test execution. Test execution is done nightly every night for as long as needed. I do not want to interrupt test execution by setting new "from " value every day prior to test execution.

And, I do not want to define x amount of similar data loops (I think that's what you suggested?) as well. Too cumbersome!

 

 

baxatob
Community Hero

Re: Data driven testing: automatically update from - to records values over testruns

You can do it programmatically, like:

 

def ddt_loop:
    dd_var = Project.Variables.your_DBTable_variable
row_to_start = 1 # Assuming the first row is a header with index == 0 row_to_end = 10
dd_var.Reset()


for i in range(row_to_start-1):
dd_var.Next()
for i in range(row_to_start, row_to_end+1): do_something() dd_var.Next()

You can assign row_to_start and row_to_end variables as you wish.

mgroen2
Super Contributor

Re: Data driven testing: automatically update from - to records values over testruns

@baxatobthanks for above piece of code.

My first question: How to integrate this in Keyword driven Test Framework?

 

Also, I have created a feature request for it. You can find it here.

Please vote for it you like the idea.

 

 

 

tristaanogre
Community Hero

Re: Data driven testing: automatically update from - to records values over testruns

Another way to look at it is to consider the data in those 100000 rows in your spreadsheet.  How much of it is required to be unique per test run?  I'm assuming that, for the most part, a good part of that data is duplicated in each record and only a few fields are unique.

What you can do is, if you only need 5 records per test run (or however many), in your keyword test use some concatenated strings to make the data unique by appending a date/time stamp.  I'm currently doing this in something similar where, each time I run a set of data from a spreadsheet, I need unique data.  The only data that needs to be unique based upon the functionality of my AUT is the name field.  So, I have 20 rows with unique names... but then I do something like Variables.CustomerData("Name") + DateTimeStamp()  where DateTimeStamp returns the current date and time in the format of yymmddhhmm. This gives me unique data each test run without having to maintain a spreadsheet of hundreds of thousands of records.  It also means that my data loop can simply be over the whole table rather than having to specify a range of rows.

 

This is achievable both in script code as well as in keyword tests... you would just specify that the data being entered is a code expression and write it out as indicated above.


 

 


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
chalvorson
Member

Re: Data driven testing: automatically update from - to records values over testruns

I'm currently running into this issue and I found this old post and thought I'd see if anyone has found a solution to this problem.  I would like to try the "Variables.CustomerData("Name") + DateTimeStamp()" option, but I can't figure out how to add this to my keyword script.  Can you please give details on how to do this: "you would just specify that the data being entered is a code expression and write it out as indicated above."  Thank you!

tristaanogre
Community Hero

Re: Data driven testing: automatically update from - to records values over testruns

Basically, where you are calling the necessary data in your keyword test, set the parameter to "Code expression" and enter the expression as indicated.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
cancel
Showing results for 
Search instead for 
Did you mean: