Using IBM RationaI FunctionaI Tester 6.

1 to run your first functionaI regression
test

Michael Kelly (Mike(MichaelDKelly.com)
Senior consultant. Fusion Alliance

First published on IBM developerWorks: http://www-130.ibm.com/developerworks/
Editor's Note: This article is based on Version 6.1 of the IBM Software Development Platform and Windows XP
Professional SP2.
You've got ÌBM® Rational® Functional Tester 6.1 for Java¯ and Web installed on your computer and have played
around with it a little, but you're still unsure how to use it to get the largest return on the time you invest in
automation. This article for novice users will take you step by step through the process of creating functional test
scripts with Rational Functional Tester.
We'll record three functional test scripts that we'll use for regression testing. The scripts will be fairly basic and
shouldn't take long to create, but while creating them we'll look at several of Functional Tester's key features. For
our application-under-test, we'll be using BookPool.com. Be aware that content changes to that site (which are
frequent) will affect the outcome of the examples contained in this article.
First, some terminoIogy
What exactly is a functional test? A functional test is a test that helps you determine whether a system functions as
intended. With a functional test, you can test both the operation and the appearance of GUÌ objects. For example,
functional testing of a command button can include testing what happens when the button is pushed as well as
testing its size, location, and color.
Ìn the context of automation, regression testing is simply playing back previously developed test scripts to compare
the latest build of the application-under-test to the baseline you established earlier. Regression testing reveals any
differences that may have been introduced into the application since the last build. You can then evaluate these
differences to determine whether they're actual defects or deliberate changes.
Choosing your tests
The first step in automated testing is to choose your tests. Choosing which tests to automate for regression testing
is both a science and an art, and it's important for you to spend time learning some strategies for doing it effectively.
You can follow some simple guiding principles and employ common sense, but more often than not, you'll also want
to mix in a healthy dose of intuition, which means that the more you do it the better you'll get. Ì don't have space
here to go into the details of choosing which test cases to automate and which to leave as manual test cases, but Ì'd
suggest that you refer to the many good articles available on this topic, as listed in the Resources section of this
article.
Creating the functionaI test project
Before you can start recording scripts, you need a functional test project to work in. To create a functional test
project, follow these steps:
1. Open ÌBM Rational Functional Tester 6.1 for Java and Web.
2. Ìf the Workspace Launcher opens, select the default workspace by clicking OK.
3. Once Functional Tester finishes opening, ensure that the Functional Test perspective is selected by clicking
the Functional Test button in the upper right corner of the screen.
4. From the menu, select File > New > Functional Test Project.
5. Ìn the Create a New Functional Test Project dialog, enter the name of the project (for our example, let's use
BookPool) and click Finish.
Figure1. The Create a New FunctionaI Test Project diaIog

This should load the project in the Functional Test Projects view.
Creating a functionaI test script
Now Ì'll walk you through recording three functional test scripts for regression testing purposes. The scripts will be
fairly basic and shouldn't take long to create, but while creating them you'll get a look at several of Functional
Tester's key features.
Before you start recording your regression scripts, you'll want to create a folder for them in the project. This will help
you avoid confusion and stay organized when you have many scripts, and it will help you out later when you need to
execute all of the regression scripts at once.
1. To create a folder, right-click the BookPool project in the Functional Test Projects view and select Add Test
Folder from the menu that pops up.
Figure 2. SeIecting Add Test FoIder from the menu

2. Enter a name for the folder (for our example, let's use RegressionScripts) and click Finish.
Figure 3. The Create a Test FoIder diaIog

You should see the folder listed under the BookPool project in the Functional Test Projects view.
Test one: Verifying that a customer can search
First, Ì'll show you how to create a test script to verify that the Web site contains the functionality to allow a customer
to search. For this test, you'll simply open the Web site, enter text into the Search field, click Search, and verify that
the correct total number of results appears and that the first three results are the books you expect.
Search
1. Right-click the RegressionScripts folder in the Functional Test Projects view and select Add Script Using
Recorder from the menu that pops up.
Figure 4. The FunctionaI Test Projects view

2. This should open the Record a New Functional Test Script wizard. Name the script (for our example, let's
use VerifySearch) and click Finish.
Figure 5. The Record a New FunctionaI Test Script wizard

3. This will open the Functional Test Recording monitor. From this monitor you can start the application you
want to test, record actions within the application, record verification points to verify results, and add data-
driven elements to the script while you're recording it. For this test, you'll simply focus on basic steps -
including the addition of some simple verification points.
Figure 6. The FunctionaI Test Recording monitor

4. Open the browser to www.BookPool.com. Click the Start AppIication icon to open the Start Application
wizard. By default no applications are listed, so you'll need to add the BookPool Web site to the list of
applications.
Figure 7. The Start AppIication wizard

5. Click the Edit AppIications List button. This opens the Application Configuration Tool.
Figure 8. The AppIication Configuration TooI

6. Click the Add button on the right. This opens the Add Application wizard to the tab that asks you to select
the type of application you're adding.
Figure 9. SeIecting appIication type in the Add AppIication wizard

7. Click the HTML Application radio button and click Next. The Add Application wizard asks you to select an
HTML application.
Figure 10. Entering the URL in the Add AppIication wizard

8. Enter the URL for the application you want to test (for our example, BookPool.com) and click Finish. This
returns you to the Application Configuration Tool, where the www.BookPool.com application should be
displayed in the Applications list.
Figure 11. The AppIication Configuration TooI

9. Click Finish. Now you should be able to see your application listed in the Application Name drop-down
menu in the Start Application wizard.
Figure 12. The Start AppIication wizard

10. Select the application and click OK. This starts the browser with the BookPool.com Web site already loaded.
Ìt may take a few seconds to open while Functional Tester works in the background.
11. Click in the search field and enter Software Testing as the search text.
Figure 13. Entering the search text in the Search fieId

12. Click the Search button. The results page should load and look similar to the following. Note that your
results may vary depending on when you record your test.
Figure 14. BookPooI.com search resuIts for "Software Testing"

Create verification points
First, to verify that all the results that were found were returned, you'll create a verification point for the HTML form
that contains "All 53 results for Software Testing."
1. Click the Ìnsert Verification Point or Action Command icon in the Functional Test Recording monitor. This
will open the Verification Point and Action Wizard.
Figure 15. The Verification Point and Action Wizard

2. Click the Object Finder icon and drag it over to the "All 53 results for Software Testing:" form in the
browser.
Figure 16. The "AII 53 resuIts for Software Testing:" form in the browser with a red Iine around it

3. Once you've selected the form, the Verification Point and Action Wizard appears again and asks you to
choose the action to perform against the form. Click the Perform Data Verification Point radio button and
click Next.
Figure 17. SeIect an Action tab, with Perform Data Verification Point seIected

4. The next screen allows you to modify some of the properties for the verification point. Change the Data
Value to Visible Text, because that text is what you're looking to verify. You can change the Verification
Point Name if you want, but the default value happens to be quite descriptive so Ì'd stick with that. Finally,
select the "Ìnclude retry parameters" checkbox, and Functional Tester will check for the existence of the
verification point in your application every two seconds, for up to 20 seconds (if you stick with the default
values; you can also enter your own values if you want). This is handy when testing Web applications
because you never know how long it will take the Web page to finish loading and rendering information.
Figure 18. Insert Verification Point Data Command tab, with VisibIe Text chosen

5. Click Next. This opens the final screen in the Verification Point and Action Wizard - the screen where you
select the properties you want to include in your verification point. This screen, which is one of the more
powerful features in Functional Tester, isn't really as complicated as it looks.
Figure 19. Verification Point Data tab, with the form AII53ResuItsForSoftwareTesting seIected

While you won't be making any changes to this screen for your test, you should be aware of its contents. The Test
Objects pane and the Recognition tab will appear for any type of verification point. The right pane will show different
information depending on what you selected in the previous screens of the wizard.
The Test Objects pane contains a tree that's a partial version of the script's object map. This hierarchical
display includes only the objects in your verification point. You can't edit the tree, but you can select an
object within it and edit its properties in the properties list in the right pane. By checking a node in the Test
Objects pane, you're including the data in that node in your verification point. Ìn the example above, you're
testing only the form you selected, not any of the parents of that form.
The Recognition tab displays recognition data used by Functional Tester to locate and manage the test
object. The Administrative tab displays internal administrative data of the object's. Neither of these tabs can
be edited. The MetaData tab, which you can edit, displays a set of properties that define how specific data is
managed.
The right pane in this case displays the object properties. Because you created a data verification point and
choose the Visible Text test, the text displays in a text box format. Ìn this text box, you can edit the data,
convert the data to regular expressions, and/or convert the data to a datapool reference for data-driven
testing.
1. Click Finish to accept the default settings.
2. Now you'll add a verification point for each of the first three books returned to ensure that the results are in
the correct order. Again, click the Ìnsert Verification Point or Action Command icon in the Functional Test
Recording monitor.
3. Using the Object Finder, select the first book in the list - or more accurately, the first cell in the search results
table. Ìn the case of our example, that book is Testing Computer Software by Cem Kaner et al. (my second
favorite book on software testing).
Figure 20. The first book in the search resuIts tabIe, with a red Iine around it
4. Once you've selected the book, click the Perform Data Verification Point radio button in the Verification Point
and Action Wizard just as in step three above and click Next.
5. On the next screen, change the Data Value to Visible Text and select the "Ìnclude retry parameters"
checkbox just as in step four above. Click Next and then Finish.
6. Repeat this process for the next two books listed in the search results.
Finish and run the script
Now you'll finish and run the script to make sure it passes.
1. Close the browser.
2. Click the Stop Recording icon in the Functional Test Recording monitor.
Functional Tester should then generate a test script that looks similar to Listing 1. (Ì removed comments to save
space.)
Listing 1. The VerifySearch regression script just recorded


package RegressionScripts;
import resources.RegressionScripts.VerifySearchHelper;
public class VerifySearch extends VerifySearchHelper
{
public void testMain(Object[] args)
{
// HTML Browser
startApp("www.BookPool.com");
// Document: Bookpool: Discount Computer Books. Welcome!:
http://www.bookpool.com/.x/nqbosf60z8/ho
text_qs().click(atPoint(72,6));
browser_htmlBrowser(document_bookpoolDiscountCompu(),DEFAULT_FLAGS).inputChars
("Software Testing");
button_search_btnGif().click();
All53ResultsForSoftwareTestVP().performTest(2.0, 20.0);
SearchResults_KanerVP().performTest(2.0, 20.0);
SearchResults_DustinVP().performTest(2.0, 20.0);
SearchResults_WhittakerVP().performTest(2.0, 20.0);
browser_htmlBrowser(document_bookpoolBooksFound(),DEFAULT_FLAGS).close();
}
}
You should also see all of the verification points and test objects listed in the Script Explorer on the right.
Figure 21. List of verification points and test objects

1. Right-click the script in the Functional Test Projects view and select Run from the menu that pops up.
Figure 22. SeIecting Run after cIicking the VerifySearch script

2. This will open the Select Log wizard. Accept the default information by clicking Finish.
Functional Tester should take over at that point and execute the test. When it finishes, the Playback Log file should
open and show that everything passed. Ìf for some reason this isn't the case, compare your code with Listing 1 to
make sure you have all the correct commands.
Figure 23. The first part of the pIayback resuIts for the VerifySearch script

Test two: Verifying adding an item to the basket
Now you'll create a test script to verify that you can add an item to your shopping basket. For this test, you'll open
the Web site, search for a specific book, add the book to your basket, and verify that the basket loads with your item
and all the correct information.
Search
1. Right-click the RegressionScripts folder and select Add Script Using Recorder from the menu that pops
up.
2. Ìn the Record a New Functional Test Script wizard, enter a name for the script (for our example, let's use
VerifyBasket) and click Finish.
3. Click the Start AppIication icon.
4. Select the BookPool.com application from the Application Name drop-down on the Start Application wizard
screen and click OK.
5. Once the browser finishes loading, click in the search field, enter Lessons Learned in Software Testing (my
favorite book on software testing) as the search text, and click the Search button.
6. From the results screen, click the Add to Basket button next to the Lessons Learned in Software Testing
book.
Create a verification point
Now you'll verify that the item is listed in the shopping basket.
1. Record a data verification point using the Visible Text option for the table cell containing the book.
Figure 24. The resuIts tabIe with a red Iine around the ceII

2. Record a data verification point using the Visible Text option to make sure that the shopping cart icon at the
top of the screen is updated to reflect the item in your cart.
Figure 25. The text for the shopping cart icon

3. Once the verifications are done, you need to remove the item from your cart. The site uses cookies (Ì think)
to store your shopping cart information. Therefore, if you don't remove it now, the next time you go to the site
it will still be in your cart and might mess up the next script that runs. To remove the item, just click the
Remove button.
Finish and run the script
1. Close the browser.
2. Click the Stop Recording icon in the Functional Test Recording monitor.
Functional Tester should then generate a test script that looks similar to Listing 2. (Ì removed comments to save
space.)
Listing 2. The VerifyBasket regression script just recorded


package RegressionScripts;
import resources.RegressionScripts.VerifySearchHelper;
public class VerifyBasket extends VerifyBasketHelper
{
public void testMain(Object[] args)
{
// HTML Browser
startApp("www.BookPool.com");
// Document: Bookpool: Discount Computer Books. Welcome!:
http://www.bookpool.com/.x/nqbosfkvb8/ho
text_qs().click(atPoint(120,9));
browser_htmlBrowser(document_bookpoolDiscountCompu(),DEFAULT_FLAGS).inputChars
("Lessons Learned in Software Testing");
button_search_btnGif().click();
// Document: Bookpool: Books Found:
http://www.bookpool.com/.x/nqbosfsev1/ss?qs=
Lessons+Learned+in+Software+Testing&x=22&y=12
button_addToCart2Gif().click();
ShoppingBasket_LessonsLearnedVP().performTest(2.0, 20.0);
ShoppingBasket_IconTextVP().performTest(2.0, 20.0);
// Document: Bookpool: Shopping Basket:
http://www.bookpool.com/.x/nqbosf15nm/ba/0471081124
button_remove().click();
browser_htmlBrowser(document_bookpoolShoppingBaske2(),MAY_EXIT).close();
}
}
Run the script to make sure it passes.
Test three: Verifying the contents of the Subjects menu
Now you'll create a test script to verify the contents of the Subjects menu on the home page of the Web site. For this
test, you'll open the Web site and simply perform a verification on the entire contents of the menu.
Open the Web site
1. Right-click the RegressionScripts folder and select Add Script Using Recorder.
2. Ìn the Record a New Functional Test Script wizard, enter a name for the script (for our example, let's use
VerifySubjects) and click Finish.
3. Click the Start AppIication icon.
4. Select the BookPool.com application from the Application Name drop-down on the Start Application wizard
screen and click OK.
Create a verification point
1. Once the browser finishes loading, click the Insert Verification Point or Action Command icon.
2. Using the Object Finder, select the Subjects table. (Ì had to go to the bottom of the table to select the entire
table.)
Figure 26. The Subjects tabIe with a red Iine around it

3. Ìn the Verification Point and Action Wizard, on the Select an Action tab select Perform a Data Verification
Point, and on the Ìnsert Verification Point Data Command tab change the Data Value to Data Grid.
4. Click Next to see the Verification Point Data tab of the Verification Point and Action Wizard. This time you'll
see a table in the right pane, containing the text from the table that you selected with the Object Finder.
Figure 27. Verification Point Data tab with our Subjects tabIe seIected
5. Double-click the first cell in the table (where it says "Artificial Ìnt: ") and another properties window will
appear.
Figure 28. The properties window for the first ceII in the tabIe

6. Ìn this window, the entire text of the Subjects menu is shown as the value of the data property for the cell.
Don't believe me? Simply select all the text and copy it to Notepad. You should see every root node in the
menu with every option under that node. This is the information you want to verify. Close this window.
7. Do the same check for the other cells that have text showing, and you'll find that they all contain text for the
items below the menu that are also contained in that table. You don't want to check those elements so you
need to limit your selection criteria. Set the selection criteria to Cell Selection using the drop-down menu in
the upper right corner that's originally set to Column Selection.
8. Select the first cell in the table and click the Update Comparison Region icon to the left of the drop-down set
to Cell Selection. Your selection should now look like the following:
Figure 29. The first ceII in the tabIe seIected in the Verification Point Data tab

9. Click Finish.
Finish and run the script
1. Close the browser.
2. Click the Stop Recording icon in the Functional Test Recording monitor.
Functional Tester should then generate a test script that looks similar to Listing 3. (Ì removed comments to save
space.)
Listing 3. The VerifySubjects regression script just recorded


package RegressionScripts;
import resources.RegressionScripts.VerifySearchHelper;
public class VerifySubjects extends VerifySubjectsHelper
{
public void testMain(Object[] args)
{
//HTML Browser
startApp("www.BookPool.com");
EntireSubjectsGridVP().performTest(2.0, 20.0);
browser_htmlBrowser(document_bookpoolDiscountCompu(),MAY_EXIT).close();
}
}
Run the script to make sure it passes.
Creating a compIete regression test script
You now have three working functional test scripts. These three scripts will serve as the baseline for your
regression. However, when you're ready to run your regression you'll most likely have hundreds of regression
scripts and won't want to run these scripts one at a time. Ìnstead, you need a way to run all of the scripts at once.
There are a couple of different ways to accomplish this. Here Ì'll show you the method Ì use.
1. Ìn the Functional Test Projects view, right-click the BookPool project and select Add Empty Script.
2. Name the script (in our example, let's use BookPool_CompleteRegression) and click Finish.
3. Functional Tester creates a blank script that looks similar to Listing 4. (Ì removed comments to save space.)
Listing 4. BIank regression script


import resources.BookPool_CompleteRegressionHelper;
public class BookPool_CompleteRegression extends
BookPool_CompleteRegressionHelper
{
public void testMain(Object[] args)
{
// TODO Insert code here
}
}
4. Delete the // TODO Insert code here comment.
5. With the cursor still on that line, right-click the RegressionScripts folder in the Functional Test Projects view
and select Insert contained scripts as "caIIScript".
6. Click Yes in the dialog that follows.
7. Functional Tester inserts a callScript command for every script in the folder, as shown in Listing 5.
Listing 5. Script updated to caII your functionaI test scripts


import resources.BookPool_CompleteRegressionHelper;
public class BookPool_CompleteRegression extends
BookPool_CompleteRegressionHelper
{
public void testMain(Object[] args)
{
callScript("RegressionScripts.VerifyBasket");
callScript("RegressionScripts.VerifySearch");
callScript("RegressionScripts.VerifySubjects");
}
}
8. Run the new script. The Playback Log should show that everything passed.
Roundup
That should be enough to get you started with Rational Functional Tester Version 6.1. Ì would encourage you to
spend a lot of time recording different types of verification points and running them to see the differences. Ì find test
folders are the best way to organize scripts for regression. They offer you a way to stay organized when executing
the scripts and they put everything in one convenient place within the project.
Check out the resources in the following section for more information on choosing the right tests to include in your
regression test suite and making sure you're automating them the best way possible. Good luck!
Resources
Participate in the discussion Iorum on this article. (You can also click Discuss at the top or bottom of the
article to access the forum.)
For practical tips on avoiding the pitfalls of automated regression testing from a group of experienced
testers, see Choosing a test automation Iramework by Cem Kaner (Kaner's Web site, 1997).
Improving the Maintainability oI Automated Test Suites by Mike Kelly (developerWorks, July 2003) describes
and demonstrates five basic automation frameworks.
For links to worthwhile reading on automated testing, see A Survey and Discussion oI Automated Testing by
Brian Marick (Testing Craft Web site).
Learn how to use model-based testing to implement random behavior in your test automation software in
Model-based testing using IBM Rational Functional Tester by Jeff Feldstein (developerWorks, January 2005).
Find more resources about IBM Rational Functional Tester.
Share your questions and views on this article with the author and other readers in the Rational discussion
Iorums.
Get involved in the developerWorks community by participating in developerWorks blogs.
Get Rational books at discounted prices from the Developer Bookstore.

About the author
Michael Kelly is currently a senior consultant for Fusion Alliance in Ìndianapolis. He's had experience managing a software
automation testing team and has been working with the Rational tools since 1999. His primary areas of interest are software
development life cycles, software test automation, and project management. Mike can be reached by e-mail.