1. 程式人生 > >Implementing the ITCL (or IBM) Framework using Rational Functional Tester

Implementing the ITCL (or IBM) Framework using Rational Functional Tester

There are many forums and communities that define the IBM framework (or ITCL framework): what it is, how it works, and its underlying advantages. The objective of this article is to focus on the implementation of the IBM framework. It will define how the IBM framework can be implemented while using IBM® Rational ®Functional Tester for automating the functional tests of an application.

The IBM framework, formerly known as the ITCL framework, was developed by the Quality Software Engineering team in collaboration with experienced automation teams throughout IBM. The framework consists of a three-tiered architecture implemented through the appobjects, tasks, and test cases packages (the IBM package).

The principles underlying the appobjects, tasks, and test cases packages are:

  • Layered architecture
  • Separation of the "what" from the "how"
  • Code reuse
  • Consistent and clear organization
  • Ability to ramp up quickly
  • Quick debugging
  • Organize files effectively
  • Enabling collaboration
  • Learning from others

Here's an explanation of appobjects, tasks, and test cases:

  • AppObjects: where you will store information about your application’s GUI elements. It is also where you will write your Getter Methods, which return objects enabling the Caller to query and manipulate these GUI elements. Typically, these methods are called within the Task layer.
  • Tasks: where you will write reusable methods that exercise common functions in your application. It is also where you will write methods to manipulate and query complex, application-specific controls. Methods in the Task are called by Test Cases.
  • Test Cases: methods that navigate through an application, verify its state, and log results.

The methodology outlined in this section defines a 5-step procedure to implement the IBM framework.

STEP 1. First, create a new project on your local drive. The project will have a repository in which you can store, maintain, compile, and run your automation code. In Functional Tester, select File > New > Functional Test Project . Name your project and click Finish .

STEP 2. Import the IBM package -- which contains utility classes that will be used extensively in the automation scripts -- into your project. Although it is possible to simply relate the path to the ibm.jar file, importing the IBM package into your project will make it easier for you to examine the package’s contents, and step into the package later when debugging. The IBM package can be downloaded from the download table at the bottom of this article.

  1. In IBM Rational Functional Tester, go to the Projects view on the left side of your screen and click on the project created in STEP 1.
  2. Select File > Import . Select Zip file and click Next . Use the Browse button to find the ibm.jar or ibm.zip file in the location you chose to store the file.
  3. Leave all settings at their default and click Finish .
  4. You should now be able to expand the name of your project in the Functional Test Projects view. You should see a folder underneath it called ibm .

STEP 3. Create a package called AppObject.

  1. In Rational Functional Tester, go to the Projects view on the left side of your screen and click on the project created in STEP 1.
  2. Pick File > New > New Test Folder .
  3. Name the folder AppObject .
  4. Click Finish .
  5. Repeat Steps 1-4 to create Tasks and TestCase folders too.

What is an AppObject Package?

In this package you have to map all the objects of the application under test. A general recommendation is to prepare separate scripts for each screen to ensure better re-use and organization of the objects and classification. For example, create a script called login that will keep all objects related to the login screen. You can also create others related to sent , inbox screens , and so on.

  1. Create an empty script in the AppObject Package.
  2. Select the AppObject package, Right-click and select Add Empty Script , as shown in Figure 1.

  1. Specify the name as Login and click Finish
  2. From the script explorer double-click Private Object Map .
  3. Make sure that the mail.yahoo.com site (or the application under test) is open.
  4. From the Private Object map, click on Test Object > Insert Object(s) , as shown in Figure 2.

  1. Drag the hand icon tool from the below dialog to the object that you want to map, as shown in Figures 3 and 4.

  1. Click Finish .
  2. Your Private Object Map screen should look like that shown in Figure 5.

  1. Select the object you recently added, right-click it, and select Add to Script AppObject.Login .
  2. Repeat steps 6-10 for all objects you want to add into this script.
  3. Click File > Save from the Private Test Object and close this. Your script explorer should look like that in Figure 6.

  1. Similarly, you can create as many scripts as you want to add into the project, and add the related objects as well.

Once you have added your objects to your object maps, you can generate your getters automatically by writing a few lines of code. These getters help you to access the objects across/with in project added in the script. You will create an empty script within the AppObject folder, and write the code shown in Listing 1 to generate the getter automatically.

  1. Create an Empty Script called getter within the AppObject folder.
  2. Create the code in Listing 1.


   3.Your Getter script contents should look like that shown in Figure 7.

  1. Run the script by selecting Script > Run .
  2. After running once, when you click your Login script it will ask you if you want to load the changes.
  3. Click Yes and you should see that your Login script has the Getter function, as shown in Figure 8.


Login function with the Getter script

STEP 4. Creating tasks

A task is the place where you will write the most reusable complex code.

  1. First Create a Script within the Tasks folder (as you did previously in the AppObject Folder).
  2. Select the Tasks folder. Right-click it and select Add Empty Script .
  3. Specify the name(LoginTask) and click Finish .
  4. Insert the code in Listing 2 into the script.

  1. Your script contents should look like that shown in Figure 9.

  1. You can add as many functions as required in the same script, or in new script(s) as per the application requirements.

Next, you are going to automate these functions.

STEP 5. Creating Test Cases

In Test Cases, you write the actual steps to perform the action. This will inherit the properties from the Tasks and the Appobject.

  1. First create a script within the Test Case folder (as you did previously in the AppObject folder).
  2. Select the Test Case folder. Right-click it and select Add Empty Script .
  3. Specify the name(YahooLogin) and click Finish .
  4. Insert the code shown in Listing 3 into the script.

  1. Your script contents should now look like those shown in Figure 10.

  6.Now run the script. it should open the browser, enter the user name and password, and then login into the Yahoo account.

The IBM framework can be implemented by following the five steps outlined in this article. The examples and code snippets herein are relevant to Rational Functional Tester. These may vary depending on whether other implementations of the IBM framework are using another tool.

Reproduced link:

http://www.ibm.com/developerworks/rational/library/06/0822_goel/