Accessing external data from the test
Setting up a data-driven test to accept data from an external text file.
You will now adapt the same test performed in the previous lesson to allow an external text file to serve as the data source.
In the
My data-driven tests
test module you created previously, create a new test case:Place your cell pointer on a line somewhere below the existing set of action lines (but before the
FINAL
section, if any).Click Create New Test Case on the toolbar.
A test case line similar to the following is inserted.
In the second column of the new line, assign the test case an ID of
TC 02
(if not already set to that value).Press
Tab
to advance to the next column, and provide a description for your test case, such asReport data from an external source
.
Select the three action lines from the previous test case (TC 01), and copy them. Do not include the test case line.
Place your cursor in the first column, five or more lines below your new test case line, and paste the text.
Now you will modify this sequence of action lines to switch data sources:
In the space between the test case heading and the use data set action line, enter the action refill data set. This is the action that connects with the data file.
With the cell pointer in the adjacent cell (data set), press the
Spacebar
and select /Rented Cars file link
, the dummy data set you created earlier.The next cell, text file, is where you specify the location and name of the text file that will serve as the data source.
Tip:Note that, if you are working on a Windows system, you have the option of using either forward or backward slashes ( / or \ ) as folder/subfolder delimiters.Finally, modify the name argument of the next action line so that use data set also points to the /
Rented Cars file link
data set.
You have completed the steps required to have a data-driven test change its data source from a data set to external text file. Your test sequence for this example should appear similar to the following:
Next, you will run the test and confirm that the data from the external file is properly read.