Create A Data-Driven Functional Test
Create A Data-Driven Functional Test
Create A Data-Driven Functional Test
ii
Contents
Create a data-driven functional test . . . 1
Introduction: Create a data-driven test . . . . . Lesson 1: Creating a project and recording a test script . . . . . . . . . . . . . . . . Creating a project . . . . . . . . . . . Starting to record . . . . . . . . . . . Starting the ClassicsCD application . . . . . Lesson 2: Data-driving a test . . . . . . . . Lesson 3: Adding descriptive headings to the data . Lesson 4: Creating a verification point with a datapool reference . . . . . . . . . . . . 1 . . . . . . 2 2 3 3 3 4 Create a verification point with a datapool reference . . . . . . . . . . . . Place the order and close the ClassicsCD application . . . . . . . . . . . Stop recording . . . . . . . . . . Lesson 5: Adding data to the datapool . . . Lesson 6: Playing back the test . . . . . Summary: Create a data-driven test . . . . . . . . . . . . . . . . . 5 . . . . . 6 6 6 7 7
. 5
iii
iv
Learning objectives
After completing this tutorial, you will be able to: v Create a project and record a test script v Data-drive a test v Add descriptive headings to the data v Create a verification point with a datapool reference v Add data to the datapool v Play back the test
Time required
30 minutes. Related information View the PDF version
Learning objectives
After completing this tutorial, you will be able to: v Create a project and record a test script v Data-drive a test v Add descriptive headings to the data v Create a verification point with a datapool reference v Add data to the datapool v Play back the test Note: Consider printing the tutorial before you begin and using the printed copy as you work through the lessons. You can print the PDF version of the tutorial or print each individual lesson by right-clicking inside each topic and then clicking Print.
Time required
This tutorial should take approximately 30 minutes to finish. If you explore other concepts related to this tutorial, it could take longer to complete.
Creating a project
Create a project to store the test assets that you need to test the Classics CD sample application. 1. Start Functional Tester. 2. Click File New Functional Test Project. 3. Type DataDriveTutorial for the name of the new project. 4. Click Finish.
Starting to record
Start recording a test script to verify that when a customer orders a music CD, the total amount charged to the credit card is the correct amount listed in the application. 1. On the Functional Test toolbar, click Record a Functional Test Script( ). 2. Type OrderTotal for the name of the test script. 3. Click Next. The Select Script Assets page opens. When you create a test script, Functional Tester creates a test datapool and other test assets. Use the defaults for Private Test Datapool and Sequential. A private test datapool is associated with only one script and is not available to any other scripts. When you use the sequential order, the test script accesses datapool records in the order that they appear in the datapool. 4. Click Finish. The Functional Tester window minimizes and the Recording Monitor opens.
2. Repeat sequentially, replacing each cell in the Variable column with a descriptive name for each heading in the Variable field. Use the text in the following variables list as descriptive names. Note: Do not use spaces in Variable names. Typically, you would look at the application to determine the appropriate headings for each row, but we have done that for you in the following variables list:
Variable Composer Item Quantity CardNo CardType ExpiryDate Name Street CityStateZip Phone
Functional Tester automatically updates the test script as you change each of the Variable names. 3. Click OK. The Insert Data Driven Actions page closes. Now the datapool has descriptive headings that make it easier to add more data. You will add more data to the datapool after you finish recording the test script.
The Datapool Reference Converter dialog box opens. In the Datapool Variable field, type Total to replace the newVariable for the heading in the datapool. If necessary, select the Add value to new record in datapool check box to add the Total to the existing datapool record you created in the previous exercise. Click OK. Click Finish.
Stop recording
On the Recording toolbar, click Stop Recording ( The test script is displayed in the editor window. ) to write all recorded information to the test script.
2. Position your mouse pointer in the datapool editor, right-click, and then click Add Record. Click OK to add a row after the first row. 3. To add a second empty row, right-click Add Record. To save time, copy the data from row 0 in the datapool into the two empty rows that you created in steps 2 and 3. 4. 5. 6. 7. 8. 9. Position the mouse pointer in the row 0 cell, right-click, and then click Copy. Position the mouse pointer in the row 1 cell, right-click, and then click Paste. Click Yes to paste the data into the empty row. Position the mouse pointer in the row 2 cell, right-click, and then click Paste. Click Yes to paste the data into the empty row. Change the value in the Quantity and Total columns to test that the ClassicsCD sample application correctly totals each order: a. In row 1, in the Quantity column, select the cell and type 2. b. In row 1, in the Total column, select the cell and type $38.98. c. In row 2, in the Quantity column, select the cell and type 3. d. In row 2, in the Total column, select the cell and type $57.97. The data in the datapool should look like the following table:
Composer Item 0 Quantity Card# CardType ExpDate Name Street CityStZip Phone Total 1234567890 Visa 09/09 Trent 75 CulpitoWall St. Ny, 212Ny 55212212 1867 $19.99 0 Composer Item Quantity Card# CardType ExpDate Name Street CityStZip Phone Total 1234567890 Visa 09/09 Trent 75 CulpitoWall St. Ny, 212Ny 55212212 1867 $19.99 Schubert String 1 Quartets Nos. 4& 14 Schubert String 2 Quartets Nos. 4& 14 Schubert String 1 Quartets Nos. 4& 14 Schubert String 1 Quartets Nos. 4& 14
1234567890 Visa
$19.99 0
1234567890 Visa
$38.98
Composer Item 2
Quantity Card# CardType ExpDate Name Street CityStZip Phone Total 1234567890 Visa 09/09 Trent 75 CulpitoWall St. Ny, 212Ny 55212212 1867 $19.99 0
Composer Item
Quantity Card# CardType ExpDate Name Street CityStZip Phone Total 1234567890 Visa 09/09 Trent 75 CulpitoWall St. Ny, 212Ny 55212212 1867 $57.97
10. On the Test Datapool tab, click X to close the datapool editor, and then click Yes to save the changes you made to the datapool.
Lessons learned
By completing this tutorial, you learned how to: v Create a project and record a test script v Data-drive a test v Add descriptive headings to the data v Create a verification point with a datapool reference v Add data to the datapool v Play back the test
Create a data-driven functional test
Additional resources
If you want to learn more about the topics covered in this tutorial, see the Data-Driving Tests section of the Functional Tester Help. Related information ibm.com eclipse.org