Introduction
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:
Here's an explanation of appobjects, tasks, and test cases:
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
STEP 3. Create a package called AppObject.
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
Figure 1. Adding an empty script
Figure 2. Inserting a test object
Figure 3. Selecting an object by dragging it
Figure 4. Object selected
Figure 5. Completed Private Object Map
Figure 6. Script Explorer for Login
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.
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); }
3.Your Getter script contents should look like that shown in Figure 7.
Figure 7. The Getter script
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.
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) { }
Figure 9. Amended script contents
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.
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 }
Figure 10. Final script
6.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.
Reproduced link:
http://www.ibm.com/developerworks/rational/library/06/0822_goel/