Adding a Data-Driven Test Case to a Test Plan

You can run a data-driven test case from a test plan as either a data-driven test case or as a regular test case. To distinguish between the two cases, there are two keywords for you to use:

If the test case is specified with the keyword ddatestcase, it is run as a data-driven test case. Use this keyword only with data-driven test cases.

To specify a data-driven test case in a test plan

  • Add keyword ddatestcase in front of the test case name.
  • Add the keyword ddatestdata as a list of queries that specify the particular rows you want the test case to run with. The list of queries is represented as a single LIST OF STRING parameter.

Rules for using data-driven keywords

  • The ddatestdata keyword requires simple select queries. To specify the row you want to run a test case with, use the ddatestdata keyword with the format: select * from <table> where ....
  • The keyword ddatestcase cannot be a level above the script file and still work. The script file has to be at the same level or above it.
  • A test plan needs to specify a test case using either the keyword testcase or the keyword ddatestcase. Using both causes a compiler error.
  • If the ddatestdata keyword is present, then the ddatestcase is run using the ddatestdata value as the rows to run.
  • The default is to run all rows for all tables. The value for ddatestdata for this is ALL_ROWS_FOR_ALL_TABLES.
  • Using the keyword testdata in a test item with keyword ddatestcase will cause a compiler error.
  • If the test case is specified with the keyword testcase, then the test case is run as a regular test case and the testdata keyword or symbols must be present to specify the value that will be passed as the regular argument. This value must be a record of the type defined for the ddatestcase, in other words of type REC_DATALIST_<Testcase name>.

You can add a data-driven test case to a test plan by using the Testplan Detail dialog box or by editing the test plan directly. However, if you edit the test plan directly, then the keywords are not automatically validated and it is your responsibility to make sure that the keywords, which are testcase versus ddatestcase and testdata versus ddatestdata, are appropriate for the intended execution of the test case.

Whenever you use the Test Detail dialog box, be sure to click the Testcases button and select the test case from the list. That will ensure that the proper keywords are inserted into the test plan.

Using sample records data within test plans

To run a test case with the sample record within a test plan, you must manually input the test data, in the format ddatestdata: {"USE_SAMPLE_RECORD_<tablename>"}

For example:

script: example.t
ddatestcase: sampletc
ddatestdata: {"USE_SAMPLE_RECORD_SpaceTable$"}

You must put the USE_SAMPLE_RECORD_ prefix in front of each table name that you want to run against. If you are using two tables, you need to input the prefix twice, as shown below with two tables named "Table1" and "Table2":

ddatestdata: {"USE_SAMPLE_RECORD_Table1","USE_SAMPLE_RECORD_Table2"}