Contents


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 framework

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.

Implementation methodology

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.

Importing the ibm.jar package

  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.

Working with the AppObject folder

  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.
Figure 1. Adding an empty script
Clicking on Adding an empty script
Clicking on Adding an empty script
  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.
Figure 2. Inserting a test object
Clicking on Inserting a test object
Clicking on Inserting a test object
  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.
Figure 3. Selecting an object by dragging it
dragging an object to select it
dragging an object to select it
Figure 4. Object selected
a red line around the object selected
a red line around the object selected
  1. Click Finish.
  2. Your Private Object Map screen should look like that shown in Figure 5.
Figure 5. Completed Private Object Map
Completed Private Object Map
Completed Private Object Map
  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.
Figure 6. Script Explorer for Login
Script Explorer for Login
Script Explorer for Login
  1. Similarly, you can create as many scripts as you want to add into the project, and add the related objects as well.

Generating AppObjects code automatically

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.
Listing 1. Code to generate getters automatically
//IMPORT THESE 2 STATEMENTS AT THE TOP OF SCRIPT
import java.util.Vector; 
import ibm.tools.ClassGenerator;
//WRITE DOWN  THE BELOW CODE IN TESTMAIN FUNCTION
public void testMain(Object[] args) 
	{
		Vector v = new Vector();
		v.addElement (new AppObject.Login ());
	//ADD ELEMENT FOR ALL THE SCRIPTS YOU HAVE IN YOUR AppObject
		new ClassGenerator().updateScripts(v);
	}
  1. Your Getter script contents should look like that shown in Figure 7.
Figure 7. The Getter script
The Getter script
The Getter script
  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.
Figure 8. Login function with the Getter script
Login function with the Getter script
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 and click Finish.
  4. Insert the code in Listing 2 into the script.
Listing 2. Login task
//DECLARE THE OBJECT OF THE SCRIPTS EXIST IN APPOBJECT 
public AppObject.Login lgn = new AppObject.Login();
….
….
public AppObject.Login lgn = new AppObject.Login();
	public void AssignLoginInfo()
	{
		lgn.getText_login().setText("abc");
		lgn.getText_passwd().setText("New1");
	}

public void testMain(Object[] args) 
{
}
  1. Your script contents should look like that shown in Figure 9.
Figure 9. Amended script contents
Amended script contents
Amended script contents
  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 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 and click Finish.
  4. Insert the code shown in Listing 3 into the script.
Listing 3. Test case
//DECLARE THE OBJECT OF THE SCRIPTS EXIST IN TASKS 
//OBJECT CREATION OF TASKS LOGINTASK SCRIPT
	public Tasks.LoginTask lt = new Tasks.LoginTask();
….
….
public void testMain(Object[] args) 
{
	//INVOKING THE BROWSER
	startBrowser("mail.yahoo.com");
	//ASSIGNED THE USER NAME AND LOGIN INFO
	lt.AssignLoginInfo();
	//CLICKED ON LOGIN/SUBMIT BUTTON
	lt.lgn.getButton_signInsubmit().click();
	//FURTHER ACTION CAN BE WRITTEN ACCORDIUNLGY		
}
  1. Your script contents should now look like those shown in Figure 10.
Figure 10. Final script
the final script
the final script
  1. Now run the script. it should open the browser, enter the user name and password, and then login into the Yahoo account.

Summary

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.


Downloadable resources


Related topics

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Rational
ArticleID=154320
ArticleTitle=Implementing the ITCL (or IBM) Framework using Rational Functional Tester
publish-date=08222006