Editor's Note: This article applies to IBM® Rational® Functional Tester versions 6.0 and 6.1.
In the Siebel test community large sets of data objects are frequently loaded on Siebel CRM systems to support test case execution. Since each Siebel release is tested on multiple geographic platforms, thousands of data objects are typically loaded into Siebel to support a test effort. Manual data entry is not efficient because it is time consuming and error prone. One solution to this problem is to extend the use of IBM Rational Functional Tester from an automated test scripting tool to an automated data loading tool. This article describes the creation of a data loading utility using Rational Functional Tester which makes the process of loading test data more efficient and accurate.
Designing test data objects and associated fields
The first step in constructing a Siebel data loading utility is to define test data objects and their associated fields. For example, a common data object used in Siebel testing is the user ID. Frequently, hundreds of user IDs need to be loaded on a Siebel system prior to testing. Each unique user ID has several fields associated with it which need to be populated in Siebel. These fields include: Login Name, First Name, Last Name, Responsibility and Position. To implement the data loading utility, create a spreadsheet containing the data associated with each test object. Save the spreadsheet in .csv file format so that it will be easy to parse later using Functional Tester. See Figure 1 as an example of a batch of user ID test objects saved in the spreadsheet userids.csv.
Figure 1. User ID test objects
Having captured the test data in a spreadsheet, define the algorithm required to load one instance of the data object in Siebel. Figure 2 is a screen shot of Siebel?s User Administration screen used to create new user IDs. This screen contains the five fields associated with the user ID data object.
Figure 2. Siebel's User Administration screen
An algorithm to create a single user ID in Siebel from this screen is:
- Click the new button to create a new record.
- Populate the Login Name field.
- Populate the First Name field.
- Populate the Last Name field.
- Populate the Responsibility field.
- Populate the Position field.
It is tedious and inefficient to manually repeat this process hundreds of times. Instead, we will automate the task using Functional Tester.
Before writing code, we must create GUI objects in Functional Tester for each web component used in the algorithm. For the user ID example, we need the following GUI objects from Figure 2:
- new button
- Login Name text box
- First Name text box
- Last Name text box
- Responsibility text box
- Position text box
Start by creating an empty Functional Tester Script named UserIDs inside the appObjects folder of Functional Tester. Double click on the Private Test Object Map associated with the UserIDs script and insert the six GUI objects listed above using the Insert Object(s) icon. The GUI objects required to implement the algorithm are now in Functional Tester. You'll see the following code in the Functional Tester Script Explorer window:
Listing 1. UsersIDs.java
package appObjects;
import resources.appObjects.UserIDsHelper;
import ibm.widgets.*;
import ibm.widgets.ancestors.*;
import ibm.widgets.swt.*;
import com.rational.test.ft.*;
import com.rational.test.ft.object.interfaces.*;
import com.rational.test.ft.script.*;
import com.rational.test.ft.value.*;
import com.rational.test.ft.vp.*;
public class UserIDs extends UserIDsHelper {
public WTextField getFirstName() {
TestObject to = FirstName(ANY, NO_STATE);
return new WTextField(to);
}
public WTextField getLastName() {
TestObject to = LastName(ANY, NO_STATE);
return new WTextField(to);
}
public WTextField getLoginName() {
TestObject to = LoginName(ANY, NO_STATE);
return new WTextField(to);
}
public WLink getNew() {
TestObject to = New(ANY, NO_STATE);
return new WLink(to);
}
public WTextField getPosition() {
TestObject to = Position(ANY, NO_STATE);
return new WTextField(to);
}
public WTextField getResponsibility() {
TestObject to = Responsibility(ANY, NO_STATE);
return new WTextField(to);
}
// --------------------------------------------------------------------------
public void testMain (Object[] args)
{
// Unit testing can go here
// (will be deleted next time ClasGenerator is run)
}
}
|
This data loading utility uses two java tasks. The first task, createUserID(),creates a single user ID in Siebel. The second task, processUserIDspreadsheet(), imports user ID data from the spreadsheet and sequentially loads it in Siebel using calls to createUserID().
Inside the tasks folder, create an Functional Tester Script named dataLoadTasks. Define the task createUserID() within this script (See Listing 2). This task is passed five parameters, representing the data used to populate each field of a user ID data object. The web components on the Siebel?s User Administration screen are accessed and populated via the GUI objects created above. Each GUI object is passed an input parameter which it uses to set the appropriate field of the Siebel?s User Administration screen. For example, inside the createUserID() task shown in Listing 2, the first line of code clicks the new button in Siebel to create a new user ID record. The next five lines set the desired data in Siebel.
Listing 2. dataLoadTasks.java
package tasks;
import ibm.util.FileOps;
import resources.tasks.dataLoadTasksHelper;
import com.rational.test.ft.*;
import com.rational.test.ft.object.interfaces.*;
import com.rational.test.ft.script.*;
import com.rational.test.ft.value.*;
import com.rational.test.ft.vp.*;
/**
* Description : XDE Tester Script
* @author admin
*/
public class dataLoadTasks extends dataLoadTasksHelper
{
/**
* Script Name : dataLoadTasks
* Generated : Mar 24, 2005 3:43:50 PM
* Description : XDE Tester Script
* Original Host : WinNT Version 5.0 Build 2195 (Service Pack 4)
*
* @since 2005/03/24
* @author admin
*/
public appObjects.UserIDs getUserIDs() {
return new appObjects.UserIDs();
}
public void createUserID(String loginID, String firstName,
String lastName, String position, String responsibility) {
getUserIDs().getNew().click();
getUserIDs().getLastName().setText(lastName);
getUserIDs().getFirstName().setText(firstName);
getUserIDs().getLoginName().setText(loginID);
getUserIDs().getResponsibility().setText(responsibility);
getUserIDs().getPosition().setText(position);
}
public void processUserIDspreadsheet(String filepath) {
String loginID, firstName, lastName, responsibility, position;
String[] alist = FileOps.getFileContentsAsList(filepath);
java.util.StringTokenizer st;
int i = 1;
while (i < alist.length) {
st = new java.util.StringTokenizer(alist[i], ",");
loginID = st.nextToken();
firstName = st.nextToken();
lastName = st.nextToken();
responsibility = st.nextToken();
position = st.nextToken();
createUserID(loginID, firstName, lastName, responsibility, position);
i = i + 1;
} // end outer while
}
public void testMain (Object[] args)
{
}
}
|
Next, define the task processUserIDspreadsheet() in the dataLoadTasks script as shown in Listing 2. This task receives a single parameter, the local path to the spreadsheet containing the data to be loaded. It reads the data spreadsheet and stores the lines of this file as a list of strings within Functional Tester. As seen in Listing 2, each line of the .csv file is parsed by extracting the strings between commas and saving them in tokens corresponding to the fields of each data object. The first token is associated with the Login Name field and the association continues until the last token is associated with the Position field. After a line is parsed the task createUserID() is called to load that data into Siebel. The process repeats until all the data in the spreadsheet has been processed.
Finally, create a script to launch the utility. Inside the tools folder, create an empty Functional Tester script named loadUserIDs. The code for loadUserIDs is found in Listing 3. This script simply calls the task processUserIDspreadsheet() with the path of the data spreadsheet as its parameter. The data loading utility is complete and can be launched from the loadUserIDs script.
Listing 3. loadUserIDs.java
package tools;
import tasks.*;
import resources.tools.loadUserIDsHelper;
import com.rational.test.ft.*;
import com.rational.test.ft.object.interfaces.*;
import com.rational.test.ft.script.*;
import com.rational.test.ft.value.*;
import com.rational.test.ft.vp.*;
/**
* Description : XDE Tester Script
* @author Robert Quinn
*/
public class loadUserIDs extends loadUserIDsHelper
{
/**
* Script Name : loadUserIDs
* Generated : Mar 24, 2005 3:44:37 PM
* Description : XDE Tester Script
* Original Host : WinNT Version 5.0 Build 2195 (Service Pack 4)
*
* @since 2005/03/24
* @author admin
*/
public void testMain (Object[] args)
{
tasks.dataLoadTasks dt = new tasks.dataLoadTasks();
dt.processUserIDspreadsheet("C:\\userids.csv");
}
}
|
Large sets of data objects frequently need to be loaded on Siebel CRM systems to support testing activity. Manual data entry is inefficient because it is time consuming and inaccurate. The Siebel data loading utility described in this article extends the use of IBM?s Rational Functional Tester from an automated test scripting tool to an automated data loading tool. It represents an effective way to automate the process of loading test data thus making it more efficient and accurate.
- Share your questions and views on this article with the author and
other readers in the Rational discussion forums.
- To learn more, visit the IBM Rational Functional Tester product area on developerWorks Rational. You'll find technical documentation, how-to articles, education, downloads, product information, and more.
- Get involved in the developerWorks community by participating in
developerWorks
blogs.
- Browse for books on these and other technical topics.
Comments (Undergoing maintenance)





