Previous Topic: Tutorial 1 - Projects, Test Cases, and PropertiesNext Topic: Tutorial 3 - Filters and Assertions


Tutorial 2 - Data Sets

In this tutorial, you learn how to create and use a simple data set. You also learn how to provide the data in a data set to a test case.

Tutorial Tasks

In this tutorial, you will:

Prerequisites

Step 1 - Create a Data Set

In this tutorial, you use a comma-delimited text file as the data set. This option is only one of several options available to create a data set. After you create the text file, you import it into the My Tutorials project.

Follow these steps:

  1. In a text editor such as Notepad, create a text file.
  2. Copy and paste the following properties and values into the text editor. Do not use spaces in the text file.
    month,day,year
    3,2,1956
    4,7,2007
    1,3,2010
    5,8,{{yearglobal}}
    8,10,2004
    12,11,{{yearglobal}}
    10,12,2007
    3,5,2011
    

    The first row specifies the names of the properties to which this data is assigned (month, day, year). The remaining rows specify the data that is read and used in the test case. Two of the rows include a property with the name yearglobal.

  3. Save the file as dates.txt.
  4. In the Project panel, right-click the Data folder in the My Tutorials project and select Import Files.
  5. Navigate to the folder where you saved the dates.txt file and select the file name.
  6. Click Open. The dates.txt file now appears in the Data folder.

Step 2 - Create a Test Case

You add a test case to the My Tutorials project.

Follow these steps:

  1. In the Project panel, right-click the Tests folder and select Create New Test Case.
  2. Make the file name tutorial2.
  3. Click Save.

Step 3 - Add a Property to the Project Configuration

The dates.txt file includes a property with the name yearglobal. In this procedure, you add the yearglobal property to the project configuration.

Follow these steps:

  1. In the Project panel, double-click project.config.
  2. Click LISA-- icon_image_whiteplussign Add to add a row.
  3. In the Key field, enter yearglobal.
  4. In the Value field, enter 1999.
  5. Click Save Main Toolbar Save icon.

Step 4 - Add a Test Step for Output Log Message

To write text out to the log, use a test step, the Output Log Message step.

Follow these steps:

  1. Click the tutorial2 tab.
  2. Click LISA--icon_image_whiteplussignbluecircle Add.

    The Add step menu is displayed.

  3. Select Utilities and select Output Log Message.

    A step with the name Output Log Message is added to the model editor.

  4. Right-click Output Log Message and select Rename. Change the name to DSstep1.
  5. In the right pane, click the arrow next to Output Log Message.

    The Output Log Message tray opens.

  6. Delete the placeholder text.
  7. Enter the following log message:
    Date is: {{month}}/{{day}}/{{year}}
    

    Note: The curly brackets are important. The test case runs correctly only if they are included.

  8. To close the Output Log Message tray, click anywhere in the model editor.
  9. Click Main Toolbar Save icon Save.

Step 5 - Create Another Output Log Message Step

Create another test step similar to the DSstep1 test step.

Follow these steps:

  1. Click LISA--icon_image_whiteplussignbluecircle Add.

    The Add step menu is displayed.

  2. Select Utilities and select Output Log Message.

    A step with the name Output Log Message is added to the model editor.

  3. Right-click Output Log Message and select Rename. Change the name to DSstep2.
  4. In the right pane, click the arrow next to Output Log Message.

    The Output Log Message tray opens.

  5. Delete the placeholder text.
  6. Enter the following log message:
    Date is: {{month}}/{{day}}/{{year}}
    
  7. To close the Output Log Message tray, click anywhere in the model editor.
  8. Click Main Toolbar Save icon Save.

Step 6 - Execute the Test

To execute the test and see what happens, use the Interactive Test Run (ITR).

Follow these steps:

  1. From the toolbar, click Blue Gear Icon Start ITR.

    The ITR opens.

  2. In the Execution History pane, click Automatically execute test LISA--icon_image_whiterightarrowongreen.
  3. When the test is complete, click OK.
  4. In the Execution History pane, click DSstep1 and DSstep2.

    Notice that the month, day, and year properties have not been replaced with actual values. This result is expected, because you have not added the data set to the test case.

Step 7 - Add the Data Set

You now add the dates.txt data set to the DSstep1 test step.

Follow these steps:

  1. In the model editor, select DSstep1.
  2. In the right pane, double-click the Data Sets step tab.
  3. Click Icon - plus sign Add below the Data Sets element.
  4. From the Common DataSets list, select Read Rows from a Delimited Data File.

    The data set is added to the test step.

    The data set editor opens in the right pane.

  5. In the data set editor, set the name to DatesDS.
  6. Click LISA--icon_image_threedotsinsquare File Location, then navigate to and select the dates.txt file in the LISA_HOME\Projects\My Tutorials\Data directory.
  7. Click the Test and Keep button.

    If the test is successful, the Data Set Editor window returns a "Test successful" message.

  8. Click OK.
  9. From the toolbar, click Blue Gear Icon Start ITR, then select Start new ITR.
  10. In the Execution History pane, click Automatically execute test LISA--icon_image_whiterightarrowongreen.
  11. When the test is complete, click OK.
  12. In the Execution History pane, click DSstep1 and DSstep2.

    The first row of data in the data set is displayed in the Response tab. Both step responses display the same date because we read only from the data set in DSstep1.

Step 8 - Change the Data Set Behavior

You now modify the data set so that it loops through the test step until all the rows in the data set are read.

Follow these steps:

  1. In the model editor, select the DSstep1 test step.
  2. In the step elements panel of DSstep1, click the arrow next to DatesDS under the Data Sets element.

    The data set editor opens.

  3. In the At end of data field, select the Execute option.
  4. Click the drop-down arrow on the Execute field and select End the Test from the list of choices that appear.

    This setting causes the test to end when all the data rows have been read.

  5. Click the Test and Keep button.
  6. Click OK to close the test successful message.
  7. In the model editor, select the DSstep2 test step.
  8. In the Step Information tab, set the Next drop-down list to DSstep1.

    This setting causes the two test steps to loop. The arrows in the model editor show the order of execution: DSstep1, followed by DSstep2, followed by DatesDS.

  9. From the toolbar, click Blue Gear Icon Start ITR, then select Start new ITR.
  10. In the ITR, click Automatically execute test LISA--icon_image_whiterightarrowongreen.

    The test case runs in a loop until there are no more data rows in the data set.

  11. When the test is complete, click OK.
  12. Click Main Toolbar Save icon Save.

Tutorial 2 - Review

In this tutorial, you: