Data driven testing using Robot framework

403 views
Skip to first unread message

Karthick

unread,
May 20, 2009, 7:39:40 AM5/20/09
to robotframework-users
Hi,

This is regarding the data-driven testing using Robot framework. There
is requirement where we have to call same keyword many times for
different argument values:.

Say for eg.

I have a keyword, <FileRowCountCheck> Argument1 - FileName & Argument
2 - Expected RowCount


My testcases would look like:

TC1 FileRowCountCheck C:/File1.txt 20
TC2 FileRowCountCheck C:/File2.txt 30
TC3 FileRowCountCheck C:/File3.txt 40


As you would see, I have to modify the testcase if I have to test for
a new file File4.txt. TO overcome this, we would like to have the
parameter values for testcases in a file. For eg:

TC1 FileRowCountCheck C:/ArgumentValuesFile.txt

C:/ArgumentValuesFile.txt would contain:
C:/File1.txt 20
C:/File2.txt 30
C:/File3.txt 40


So, if I have to re-run the testcases for few additional files,
instead of changing the testcase, I can just add that new row in the
ArgumentValuesFile.txt to acheive this.

Please let me know if there is a way in Robot to address this case.

Let me know if you would require any further details to respond to
this.

Thanks,
Karthick

Martin Taylor

unread,
May 20, 2009, 8:36:35 AM5/20/09
to robotframework-users
I would LOVE IT if RF did this, too, except that I think the data
files would have to be CSV or TSV rather than plain TXT to be more
easily parsable into rows of parameters. I'm currently porting >2M
test cases from an older in-house data driven testing tool into RF.
The old tool worked like what you're asking for EXCEPT that the single
keyword equated to a single test rather than each row of data equating
to a single test. This was a big problem for result reporting, so I'm
glad to move to RF for that reason alone. However, your suggested
notation in RF would be MUCH MORE EFFICIENT that the current way data
driven testing is done.

Perhaps this should be raised as an enhancement request and we can get
other users to vote on it by the "star" system?

Thanks,
Martin

Ram

unread,
May 20, 2009, 10:40:45 AM5/20/09
to robotframework-users
I would also love to see this feature in RF.
Regards,
Ram

Karthick

unread,
May 21, 2009, 2:39:48 AM5/21/09
to robotframework-users
Thanks for your response Martin.

As you had highlighted it would make RF much more efficient for
datadriven testing if we have this feature. Also, it would be better
to have the argument file as CSV or TSV, very valid point to
consider.

Hoping to get a favourable response from Robot enhancement team.

Thanks,
Karthick
> > Karthick- Hide quoted text -
>
> - Show quoted text -

RobotUser

unread,
May 21, 2009, 9:57:33 AM5/21/09
to robotframework-users
This will definitely help all of us and will save lot of labor work
too.

My fingers are crossed.

--RobotUser

Radek

unread,
May 21, 2009, 10:07:08 AM5/21/09
to robotframework-users
What you are asking for is indirectly built in into RF. Why not make
use of variable files? Why not make use of 'Get File' keyword to read
the file and then extended variable syntax to split the lines and
split the commas within :FOR loops (and create re-usable keyword to
read CVS files)? You can return lists or dictionaries from your
keywords and use :FOR loops to run commands over those values.

Read the user guide on :FOR construct, operating system library,
collection library. Some Python knowledge will also help if use use
extended variable syntax.

--
Radek

Martin Taylor

unread,
May 21, 2009, 10:27:49 AM5/21/09
to robotframework-users
Why not? For one simple reason: This would turn all the separate
tests represented by each line of data in the CSV file into a single
RF test. That's certainly not what I want. What I believe we're asking
for it to keep the "one row of data equates to one test" paradigm that
is present in the current RF DDT technique described in the RF User
Guide, BUT not not have to write a huge test suite repeating the
single keyword multiple time with the data maintained in the RF Test
Suite file. If implemented, this requested feature would maintain a
cleaner separation between the test data that drives the tests and the
keyword that implements the test.

An implementation scheme might be as follows:

| *TestName* | *Action* | *Argument* |
*Argument* |
| My DDT | Execute DDT | My DDT Driver KW | C:\PathTo
\MyDDTData.csv |

Where "Execute DDT" is the new RF built-in keyword for this feature,
"My DDT Driver KW" is the keyword to be run on each row of data and "C:
\PathTo\MyDDTData.csv" is the path to the DDT data file driving these
tests. The format for the CSV file would be that the first column
must be "TestName" and the remaining columns would be arguments passed
to "My DDT Driver KW". The thing that would make this very special is
that the TestName "My DDT" would become in effect a SuiteName. The
built-in KW "Execute DDT" would iterate through the rows of the CSV
file, making a separate RF test out of each row's call to "My DDT
Driver KW" with its row of arguments.

Karthick

unread,
May 22, 2009, 2:32:51 AM5/22/09
to robotframework-users
Radek,

Happy to know that there is a way to do this in RF itself. Can you
please throw some light on the proposed approach.

Say my testcase is something like this:
TC1 FileRowCountCheck C:/ArgumentValuesFile.csv

C:/ArgumentValuesFile.csvwould contain:
C:/File1.txt,20
C:/File2.txt,30
C:/File3.txt,40

As I had explained earlier, I do not want to modify the testcase for
adding similar check on File4.txt,50 ....

Can you please explain how the same can be acheived using GET FILE &
FOR loop approach.

Thanks,
Karthick
Reply all
Reply to author
Forward
0 new messages