Sunteți pe pagina 1din 17

Rational

Automate a manual test that is based on keywords

ii

IBM Rational Automate a manual test that is based on keywords

Contents
Automate a manual test that is based on keywords . . . . . . . . . . . . . . 1
Introduction: Automate a manual test that is based on keywords . . . . . . . . . . . . . Module 1: Use keywords to create a manual test . Lesson 1: Create a manual test project . . . . Lesson 2: Create keywords. . . . . . . . Lesson 3: Create a manual test script using keywords . . . . . . . . . . . . . Lesson 4: Create a datapool . . . . . . . Lesson 5: Reuse keywords in a new manual test script . . . . . . . . . . . . . . . Module 2: Create automated functional test scripts and associate them with keywords . . . . . . . . . . 1 2 2 2 Lesson 1: Create a functional test project and associate it with a manual test project . . . Lesson 2: Record scripts based on predefined keywords . . . . . . . . . . . . Lesson 3: Publish automated scripts . . . Module 3: Run scripts . . . . . . . . . Lesson 1: Run a partially automated keyword-enabled test script . . . . . . Lesson 2: View the test log . . . . . . Summary: Automate a manual test that is based keywords . . . . . . . . . . . . . . . . . . 8 . 8 . 10 . 11

. 4 . 5 . 6 . 7

. . 12 . . 12 on . . 13

Copyright IBM Corp. 2007

iii

iv

IBM Rational Automate a manual test that is based on keywords

Automate a manual test that is based on keywords


This tutorial walks you through the major use cases for creating keywords, creating keyword-enabled manual test scripts, associating keywords to automated test scripts, and running the keyword-enabled manual test scripts. This comprehensive tutorial uses a sample Java application that is installed with the product.

Learning objectives
After completing this tutorial, you will be able to use keywords to automate a manual test.

Time required
60 minutes Related information View the PDF version Tutorial: Create a functional test Tutorial: Create a data-driven functional test

Introduction: Automate a manual test that is based on keywords


In this tutorial you learn how to get started using keywords to create a manual test and automate it. It uses IBM Rational Manual Tester and Rational Functional Tester to perform all tasks. The tutorial is divided into three modules that must be completed in sequence to work properly.

Learning objectives
After completing this tutorial, you will be able to: v Define keywords in a manual test environment v Use the keywords in a manual test script v Create automated test scripts and associate them with the keywords in a functional test environment v Run keyword-enabled manual test scripts from your manual test environment v View test logs Note: Consider printing the tutorial before you begin and using the printed copy as you work through the lessons. You can either print the PDF version of the tutorial or print each individual lesson by right-clicking inside each topic and clicking Print.

Time required
This tutorial takes approximately 60 minutes to finish. If you explore other concepts related to this tutorial, it might take longer to complete.

Prerequisites
You must have both Rational Functional Tester and Rational Manual Tester installed on your computer.

Copyright IBM Corp. 2007

Module 1: Use keywords to create a manual test


In this module you learn how to use keywords to create a manual test. This module is divided into five lessons that must be completed in sequence for the tutorial to work properly.

Learning objectives
After completing the lessons in this module, you will understand how to do the following tasks: v Create a manual test project and keyword library v Create keywords v Create a manual test script using keywords v Create a datapool v Reuse keywords in other manual test scripts

Time required
This module takes approximately 15 minutes to complete.

Prerequisites
This module requires that you to have Rational Manual Tester installed on your computer.

Lesson 1: Create a manual test project


In this lesson, you create a manual test project and a keyword library. A keyword library houses a reusable set of keywords that can be added to new or existing scripts. Start Rational Manual Tester and then perform the following tasks to create a new manual test project and keyword library. 1. Click File New Project 2. Type C:\KeywordProject in the Directory field. 3. Type AutomateKeywordTutorial in the Project name field. 4. Click Finish. After the new project is created, a new keyword library with the same project name is created automatically. To view the keyword library expand the Library folder in Project Explorer.

You are now ready to define new keywords in the keyword library.

Lesson 2: Create keywords


In this lesson, you will define keywords in the keyword library.

IBM Rational Automate a manual test that is based on keywords

A keyword is a reusable manual test statement or group of manual test statements. Keywords can be reused in other test scripts within the project and shared with other members of your test team. You can also associate these keywords with automated test scripts. To create new keywords: 1. Optional: By default, the Keyword view is open. If not, select Window Show View Keywords to open the Keyword view. 2. In the Keyword view, click the New Keyword icon ( ). 3. Type the name of the keyword included in the following table in the Name field and click OK.
Table 1. Keyword Start application Order CDs Steps Start the application Select a composer Select a CD title Click Place Order Login as an existing customer Select the customer [[Customer name]] Type xxxx in the Password field Click OK Specify details and place order Enter a credit card number, for example, 7777777777777777 Enter an expiration date, for example, 07/017 Click Place Order Verify order Verify that the order is for the correct customer

After you create a new keyword, it opens in the Script Editor. 4. Type the keyword step statements for the keyword in the Script Editor from Table 1. 5. Click File Save to save the keyword. 6. Repeat this process for each keyword listed in Table 1 7. After you define all the keywords, the Libraries View will show:

Automate a manual test that is based on keywords

Lesson 3: Create a manual test script using keywords


In this lesson, you will create a manual test script using the keywords that you defined in the previous lesson. A script is a series of test statements, or instructions, that are presented in a logical order. A script might contain both keyword-enabled steps and manual steps. In this lesson you will create a manual test script that is fully keyword-enabled. To create a new manual test script: 1. Click File New. A new, untitled script opens for editing in the Authoring Editor. 2. In the Keyword view, select the Start application keyword, and drag it to the right of the first step icon ( ) in the untitled script; then press Enter. By default, the keyword library in the Keyword view appear expanded. If not, expand the Keyword library icon ( ). 3. Continue adding keywords until you have included all the keywords that you created in the previous lesson. Your manual test script looks as follows:

IBM Rational Automate a manual test that is based on keywords

4. Click File Save. 5. Type the name of the script as AutomateKeywordTutorial.rmt and click OK. The saved script is displayed in the Project explorer under the Script folder.

Lesson 4: Create a datapool


In this lesson, you create a datapool. A datapool is a test dataset, a collection of related data records that supplies data values to the variables in a test script during execution. You will data-drive the existing customer list to vary the customer information at run time when you execute the test script. Learn more about datapools: When you data-drive a test, you insert variables instead of literal values into your test script. At runtime, the variables are replaced with data from the datapool. In this way you can use a single script to test multiple data records. Datapools can be shared with other team members and offer a powerful way to extend test coverage. To 1. 2. 3. create a new datapool: Right-click in the Project Explorer and select New Datapool. Type Customer list in the Datapool name field. Click Finish.

Add data
To add data to the datapool: 1. Right-click in the Datapool Editor and select Add Variable.
Automate a manual test that is based on keywords

2. Type Customer name in the Name field. 3. Right-click in the Datapool Editor and select Add Record. The addition of a new record is indicated by a record number in the Datapool Editor. 4. Double-click the cell next to the record number and type the record value. Create the following two records: v Trent Culpito v Susan Flontly 5. Click File Save to save the datapool.

Associate a datapool with a script


After you create the new datapool, associate it with a test script. To associate a datapool with a script: 1. In the Project Explorer, right-click Customer list.rftdp and select Associate with Script(s). 2. Select AutomateKeywordTutorial.rmt and click Finish.

Insert a datapool column in a script


Insert a datapool column in a manual test script in order to data-drive the script. To 1. 2. 3. 4. insert a datapool column in a script: Open the KeywordTutorial.rmt manual test script. Select [[Customer name]] under the Login as an existing customer keyword. Right-click and select Insert Datapool Column. Select Customer Name from the Select a Datapool Column list and click OK.

Lesson 5: Reuse keywords in a new manual test script


In this lesson, you learn how to reuse keywords in other scripts. In this lesson, you create new keywords, create a new manual test script, and reuse existing keywords to change the workflow of the test script. To reuse keywords in a new script: 1. Define two new keywords in the AutomateKeywordTutorial.kwl keyword library as follows: v Login as new customer v Specify customer details 2. Create a new manual test script and name it AutomateKeywordTutorialReuse.rmt. 3. Insert the keywords from the Keyword Library view into the test script in the following order:

IBM Rational Automate a manual test that is based on keywords

You now have a new script that contains common keywords. Although the first script you created in a previous lesson will log in to the test application as an existing customer, the new script will log in as a new customer.

Module 2: Create automated functional test scripts and associate them with keywords
In this module you learn how to create automated functional test scripts in Rational Functional Tester and associate the scripts with keywords. This module is divided into three lessons that must be completed in sequence for the tutorial to work properly.

Learning objectives
After you complete the lessons in this module you will understand how to do the following: v Create a functional test project and associate it with a manual test project v Record automated test scripts based on predefined keywords v Publish automated test scripts

Time required
This module takes approximately 30 minutes to complete.

Prerequisites
This module requires that you have both Rational Manual Tester and Rational Functional Tester installed on your computer.

Automate a manual test that is based on keywords

Lesson 1: Create a functional test project and associate it with a manual test project
In this lesson, you create a functional test project and associate it with a manual test project. In order to view the keywords defined in a manual test project in Functional Tester, you must associate a functional test project with a manual test project. Start Rational Functional Tester and then perform the following tasks before you record your first test script. To 1. 2. 3. 4. create a new functional test project and associate it with a manual test project: Click File New Functional Test Project. Under Project name, type FTKeywordtutorial (no spaces). Under Project location, type C:\FTKeywordproject. Functional Tester creates this directory. Select Associate the project to a Manual Test Project.

5. Under Manual Test Project Location, type C:\KeywordProject\AutomateKeywordTutorial. Alternatively, you can browse to your manual test project location and select the project. 6. Under Manual Test Project Name, type AutomateKeywordTutorial. 7. Click Finish. The FTKeywordtutorial project is displayed in the Functional Test Projects view, which is the left pane in the Functional Test perspective. The Keyword Library view displays the keywords.

Lesson 2: Record scripts based on predefined keywords


In this lesson, you record automated scripts based on the keywords you defined in the previous lessons. You can either create new automated scripts for the keywords or associate existing scripts with keywords. In this lesson, you learn how to create new automated functional test scripts and associate with keywords. In this lesson you create automated scripts for the following keywords: v Start application v Order CDs v Specify details and place order v Verify order v Login as new customer v Specify customer details Note: You do not create an automated script for the keyword Login as an existing customer. This way you will understand how the execution behaves when the manual test script contains both manual and automated keywords in the next module.

Start application
To create an automated script for the keyword Start application: 1. In the Keyword Library view, right-click the Start application keyword and click Record. 2. Click Finish. 3. In the Recording Monitor toolbar, click the Start Application icon ( ). 4. Select ClassicsJavaA and click OK. The Functional Tester sample application, ClassicsCD, opens. 5. In the Recording Monitor toolbar, click the Stop Recording icon ( ).

IBM Rational Automate a manual test that is based on keywords

A new functional test script Startapplication is created and displayed in the Functional Test Projects view. Important: Leave the test application open. This is required to record scripts for the rest of the keywords.

Order CDs
To 1. 2. 3. 4. 5. 6. create an automated script for the keyword Order CDs: In the Keyword Library view, right-click the Order CDs keyword and select Record. Click Finish. Click the + next to Haydn to expand the folder in the Composers tree. In the list, click Symphonies Nos. 94 & 98. Select Order Place New Order in the ClassicsCD toolbar, . In the Recording Monitor toolbar, click the Stop Recording icon ( ).

A new functional test script OrderCDs is created and displayed in the Functional Test Projects view.

Specify details and place order


To create an automated script for the keyword Specify details and place order: 1. In the Keyword Library view, right-click the Specify details and place order keyword and select Record. 2. Click Finish. 3. In the card number field, type a credit card number. You must use the valid format of four sets of four digits, for example 7777777777777777. 4. In the expiration date field, type a valid format expiration date, for example 07/07. 5. Click Place Order. 6. Click OK in the order confirmation message window. 7. In the Recording Monitor toolbar, click the Stop Recording icon (

).

A new functional test script Specifydetailsandplaceorder is created and displayed in the Functional Test Projects view.

Verify order
To create an automated script for the keyword Verify order: 1. In the Keyword Library view, right-click the Verify order keyword and select Record. 2. Click Finish. 3. In the ClassicsCD application, click Order View Existing Order Status. Do not click either of the password fields at this time. 4. Click OK. You will test the label Order for Trent Culpito in the View Existing Orders window. 5. In the Recording Monitor, click the Insert Verification Point or Action Command button ( ). 6. In the Select an Object page, select After selecting an object advance to next page. 7. Drag the Object Finder over the label Order for Trent Culpito to select it. While holding down the mouse button, note that the label is outlined with a red border and the object name is displayed (javax.swing.JLabel). After you select the object, the Select an Action page opens because you opted in the previous step to advance to next page. 8. Select Perform a Properties Verification Point, which is the second action from the top, and then click Next. 9. Accept the suggested default on the Insert Properties Verification Point Command page and click Next. Note: Make sure that the Include Children field is set to None.

Automate a manual test that is based on keywords

10. In the Property column select the text, opaque, and visible properties to test them during playback. You may have to click the check box twice for the selection to persist. 11. Click Finish. 12. In the ClassicsCD View Existing Orders window, click Close. 13. Close the ClassicsCD application by clicking the x button. 14. In the Recording Monitor toolbar, click the Stop Recording icon ( ).

A new functional test script Verifyorder is created and displayed in the Functional Test Projects view.

Login as new customer


To 1. 2. 3. 4. 5. create an automated script for the keyword Login as an new customer: In the Keyword Library view, right-click the Login as an new customer keyword and select Record. Click Finish. Select the New Customer option. Click OK In the Recording Monitor toolbar, click the Stop Recording icon ( ).

A new functional test script Loginasnewcustomer is created and displayed in the Functional Test Projects view.

Specify customer details


To create an automated script for the keyword Specify customer details: 1. In the Keyword Library view, right-click the Specify customer details keyword and select Record. 2. Click Finish. 3. In the Place an Order dialog box, type the following details:
Table 2. Field Name Street City, State, Zip Phone Value Susan Culpito 75 Wall St 22nd Fl NY, NY 12212 212-552-1867

4. In the Recording Monitor toolbar, click the Stop Recording icon (

).

A new functional test script Specifycustomerdetails is created and displayed in the Functional Test Projects view. You now have automated scripts for all the keywords.

Lesson 3: Publish automated scripts


In this lesson, you publish the newly created automated scripts to a manual test project. Because creating automated functional test scripts take place in Rational Functional Tester, you must publish these scripts to a manual test project so that Rational Manual Tester accepts the association. After you establish this association, you can run the manual test scripts and all associated automated scripts from Rational Manual Tester.. To publish automated functional test scripts: 1. Right-click the Project Explorer and select Publish for Keywords. 2. In the Select Items to Publish for Keyword window, select FTKeywordTutorial.

10

IBM Rational Automate a manual test that is based on keywords

Note: By default, the automated scripts are copied to the manual test project parent directory. 3. Click Finish. You are ready to execute the manual test scripts and all associated automated scripts from Rational Manual Tester.

Module 3: Run scripts


In this module, you learn how to run a partially automated keyword-enabled test script. This module is divided into two lessons that must be completed in sequence for the tutorial to work properly.

Learning objectives
After you complete the lessons in this module you will understand how to do the following tasks: v Run a partially automated keyword-enabled test script
Automate a manual test that is based on keywords

11

v View test logs

Time required
This module takes approximately 15 minutes to complete.

Lesson 1: Run a partially automated keyword-enabled test script


In this lesson, you run the partially automated keyword-enabled test scripts that you created in previous lessons. You can run keyword-enabled test scripts that are fully automated, partially automated, or non-automated. In the previous modules you created two fully keyword-enabled test scripts. In this lesson, you run these scripts in automated mode. But since one of the keywords does not have an associated automated functional test script, you perform the steps for that keyword manually in Rational Manual Tester.

Set run preferences


Set the script execution mode before you actually start running the test scripts. To set run preferences: 1. In Rational Manual Tester, select Window Preferences. 2. In the Main Preferences tab, select the Automated option for Force execution mode to be. 3. Click OK.

Run the script


After you have set the execution mode, you are ready to run the test scripts. To run a partially automated keyword-enabled script: 1. In the Project explorer, double-click AutomateKeywordTutorial.rmt to open the test script. 2. Click Run Run Script. Rational Manual Tester is minimized and the Keyword Playback Monitor starts. As the script plays back, the Playback Monitor displays the current statement that is playing. Important: Notice that the test pauses as soon as the Login as an existing customer keyword is selected in the Playback Monitor. There is no automated script that is related to this keyword; hence it is regarded as a manual keyword statement. 3. In the Playback Monitor, click Perform the action(s) manually . 4. In the Member Logon dialog box of the ClassicsCD application, select the customer name (for example Trent Culpito) displayed in the statement from the Full Name list. 5. In the Playback Monitor, click Apply. Continue in this manner until all the manual steps have been performed. 6. Click Resume the execution to continue running the script.

Note: Notice that the script runs for a second time with a different customer name from the datapool. When the test run is complete, a log is displayed in the Project Explorer under the Logs folder.

Lesson 2: View the test log


In this lesson, you view the test log that is generated for the script execution. The Overview page in the Log viewer displays general information about the test. The Events page displays details about individual test results.

12

IBM Rational Automate a manual test that is based on keywords

To 1. 2. 3.

view a test log: In the Project Explorer, expand the Logs folder. Double-click the log that you want to view. The log opens in the Log Viewer. Click the Events tab to view results of individual test statements.

Notice that the manual keyword statements have different icons than keywords that are associated with automated scripts.

Summary: Automate a manual test that is based on keywords


This tutorial has shown you how to define keywords, associate them with automated test scripts, and then run the test scripts.

Lessons learned
By completing this tutorial, you learned how to perform the following tasks: v Define keywords v Create and associate automated test scripts with keywords v Run keyword scripts v View and analyze logs

Additional resources
If you want to learn more about the topics that are covered in this tutorial, consult the following resources: v Functional Tester Help v Manual Tester Help v Functional Tester Welcome Page v Manual Tester Welcome Page Related information ibm.com eclipse.org

Automate a manual test that is based on keywords

13

S-ar putea să vă placă și