Skip to main content

Using IBM Rational Robot Test Automation Framework Support (RRAFS) to Test Mainframe Applications

Jirong Hu (hujirong888@yahoo.com), Rational tools consultant, IBM, Software Group
Jirong Hu is currently working for IBM Rational Canada as a Rational tools consultant, mainly working in the areas of software process, change control, and quality and configuration managerment.

Summary:  This article is an extension of Getting Started: IBM Rational Robot Test Automation Framework Support (RRAFS). Here the author explores using RRAFS for automated testing of mainframe applications.

Date:  05 Jul 2006 (Published 13 Jun 2005)
Level:  Introductory
Activity:  613 views

Introduction

In our organization, all mainframe applications are accessed via a standard terminal emulator (WRQ Reflection® for IBM®) from Microsoft Windows® workstations. Other organizations may use similar tools such as Attachmate™ or NetManage® Rumba®. With IBM® Rational® Robot and Rational Robot Test Automation Framework Support (RRAFS) installed on the same workstation with Reflection software (or other terminal emulator software), the connection between Robot and mainframe applications is established as shown in Figure 1:

Figure 1: Connecting Robot and mainframe via terminal emulators
Figure 1: Connecting Robot and mainframe via terminal emulators

Identifying the objects

As with most other terminal emulators, the Reflection window (by which I mean the window that looks like the screen of a host terminal) is text-based. Therefore, we cannot use Robot's object-recognition method, since there are no objects inside the terminal window. However, the main Reflection window, toolbar, and menus are still standard Windows objects.

To identify the Reflection window, we use the Reflections window's caption. In the following sample application, it is the current date, "2/27/2004", as shown in Figure 2.

Application with current date as window caption
Figure 2: Our application with current date as window caption

Figure 3 depicts an IBM sample application running on Reflection software.

Figure 3: Reflection for IBM Internal Sample Application
Figure 3: Reflection for IBM Internal Sample Application

Usually the Reflection window caption remains the same throughout the application, which makes our MAP table very simple when using RRAFS, as illustrated in Figure 4.

Figure 4: Identifying Reflection window in map file
Figure 4: Identifying Reflection window in map file

In our organization, we manually launch Reflection software before we start testing, so that Robot can find it with the above setting. To facilitate this, the application team always gives us a Reflection configuration file. We just need to copy it to test workstations and double-click it to launch the Reflection window.


Driving the applications

For automation purposes, Reflection applications are best driven by the keyboard. We use InputKeys command to send the keystrokes to the Reflection window. Two types of keys are used for automation. One is used to enter application data such as "u004" (which is a user ID) in the following sample. The other type includes special characters such as "{Tab}" and "{Enter}" to move the cursor from one position to another, or to drive the application from one screen to the next.

For example, Figure 5 shows the following commands, which enter a user id, go to the next screen, and pause (stop for one second).

Figure 5: Sending Keystrokes to Drive the Application
Figure 5: Sending Keystrokes to Drive the Application

Validating the data

Besides making the application flow, another major task in test automation is to validate various application data and messages on the terminal screen. This is either to make sure we are on the correct screen or to validate the results.

We present two approaches to data validation in this article: using an Image VP plus OCR, or extending the RRAFS to support HLLAPI.

Using Image VP and OCR

Image VP and OCR are Robot's built-in features. For example, the following steps illustrate how to confirm that we are actually at the "Welcome" page shown in Figure 6:

Figure 6: Validating the Welcome Screen
Figure 6: Validating the Welcome Screen
  1. Record a GUI script and create a Regional Image VP WelcomeMsg with OCR value WELCOME in Robot (Figure 7).
Figure 7: Record a test script and create a Regional Image VP
Figure 7: Record a test script and create a Regional Image VP
  1. Reference the VP in the RRAFS MAP table (Figure 8) as WelcomeMsg="45,86,226,106". The coordinators come from the previously recorded GUI script.
Figure 8: Referencing the VP in the map file
  1. Copy the above VP into the main CycleDriver script, with results such as those in Figure 9. You do not really need the recorded script (for example, CICS_VP_WelcomeScreen, as seen in Figure 7) anymore.
Figure 9: Creating a Regional Image VP with OCR
  1. Create test steps in a STEP table (Figure 10).
Figure 10: The STEP table

In the above STEP table, HourGlass, StatusBar, and WelcomeMsg are all Regional Image VPs created in Robot. You can actually store all Image VPs in the main CycleDriver script, where they will be available to the RRAFS engine at runtime. The following is the set of instructions from the RRAFS online reference document on how to use a Regional Image VP:

WindowFunctions::VerifyImage
"Performs a GenericObjectVP CompareImage OR a RegionImageVP on an object. The benchmark VP must already exist and be an asset of the currently running script. A RegionImageVP can be accomplished by having the name of the VP as an item under the component in the application map. The item's value must be the coordinate values required by the RegionImageVP (i.e. "65,100,200,250")."

Challenges using Image VP and OCR

We know an Image VP is not robust. An OCR VP which is eventually based on an Image VP has the same issues. Another problem with OCR is that it does not perform very well with different screen fonts and colors. For example, Figure 11 illustrates that the built-in OCR in Robot is not able to detect the text with the original Reflection for IBM internal sample, which has a dark background and blue text.

Figure 11: Robot OCR does not work well with this color

Therefore, you may need to adjust the color scheme of your applications for automation, as shown in Figure 12.

Figure 12: Adjust your color scheme so that Robot OCR works

As usual, when you run the test, you must make sure that the screen resolution and size are exactly the same as that which you were recording. Otherwise, the Image VP and the OCR VP will fail.

Using HLLAPI

Like most other mainframe emulators, Reflection for IBM supports HLLAPI. While Robot can directly call Visual Basic APIs, it also provides a way for us to use HLLAPI from RRAFS (you can find all sample source code in the files listed in the Running the Sample section).

The validation API

The HLLAPI provides all types of methods that allow you to communicate with the terminal screen. (You can actually fully drive an application using HLLAPI, from establishing a connection to the mainframe to entering application data.) For example, the following API allows you to get the screen text from an exact location indicated by row and column:

Syntax DisplayText = object.GetDisplayText(Row, Column, Chars)
Description:
Returns text displayed in the host screen.
For example, the following commands set the value of the displayText variable equal to the display characters located in the terminal window starting at row 3, column 2 and continuing forward 30 characters:
Dim displayText As String
displayText = Session.GetDisplayText(3,2,30)

The above API makes it possible for Robot to get the screen text during testing, and then use that text for data and message validation.

For mainframe applications, the UIs are usually simpler than normal web applications, because the data and message positions do not change a lot when the application is ready for system testing. The application experts in our organization assure me that this is true, so we are quite safe using this method to retrieve the data and message fields from the terminal screen during regression testing.

We can make an easy-to-use API for test developers, as shown in Figure 13:

Figure 13: A date validation API
Figure 13: A date validation API
(click here to enlarge)

The test developers can call the above API from any Robot scripts, as shown in Figure 14:

Figure 14: Calling the validation API

A new RRAFS command

It will be useful to make the above API available as a RRAFS command, just like any other standard Component and Driver commands. For example, we would like to use a new Driver command for validation, as illustrated by Figure 15:

Figure 15: A new RRAFS driver command

RRAFS provides many ways for us to add new commands. The easiest is probably to add a new Custom Driver command. To implement a new Custom Driver Command, you just need to add a few lines into CustomDriverCommands.sbl, as shown in Figure 16.

Figure 16: Implement a new Custom Driver command
Figure 16: Implement a new Custom Driver command
(click here to enlarge)

Compile this library and add it to your project SQABasic path, and then you can start to use this Customer Driver command.


Controlling the pace

Without any object in the Reflection window, we can no longer use "WaitForXXX" Driver commands to manage the synchronization between the client and server.

The good news is that a terminal emulator normally has a busy indicator showing that it is sending requests to the server (or waiting for a response from the server) as shown in Figure 17 and 18, respectively.

Figure 17: A Busy indicator

Figure 18: The communication is complete

What we can do is: create an Image VP on that busy indicator and "once a send key has been pressed a compare should be made that waits for the indicator to appear followed immediately by one that waits for it to disappear." (see Mainframe Application Testing in the Resources section following)

With RRAFS, we can also create two Image VPs--one for the busy indicator and another with an empty content--as shown in Figures 19 and 20, respectively:

Figure 19: A busy indicator Image VP

Figure 20: StatusBar Image VP (empty)

The STEP table sample in Figure 21 demonstrates this technique:

Figure 21: Sample for synchronization

You should adjust the Verification Point wait time based on the behavior (response time) of your particular application, as shown in Figure 22.

Figure 22: Adjust the VP wait time

Exiting the application

If a system error occurs in most of our mainframe/CICS applications, the current transaction will be terminated. In this case, the current test case should be aborted immediately.

If you continue sending keystrokes to the screen, you will encounter terminal lock-up. This situation must be avoided. Based on your application's behavior, you may need different ways to handle different errors. For example, in our applications, the standard error message will be displayed in the message line, just above the function key line in the lower part of screen. Therefore, you should check these error messages when necessary, depending on your application.

Figure 23: Check error messages

A nice way to exit a test case is using the following commands:

  • C, ExitCycle : to exit running tables all the way out of the running CYCLE
  • C, ExitSuite : to exit running tables all the way out of the running SUITE
  • C, ExitStep : to exit out of the currently active table

Now You Try It

If you have Reflection for IBM installed, you can try out the following sample. The code has been tested on Reflection for IBM version 9.04 and Robot v2002.05.20.

Configuring the Sample

There is an internal sample that comes with Reflection for IBM software. Steps 1-5 configure a connection to a demonstration host and create a LocalDemo settings file that you can use for practice.

  1. Open a new (untitled) Reflection session. (You can use the New Session command on the File menu to open a new untitled session.)
  2. Click Connection > Session Setup. Under Session, set Type to either 5250 Terminal or 3270 Terminal. Under Transport, set Type to Demonstration. Select the Simulation filename for the session type you selected. Click OK to close the Session Setup dialog box.
  3. Before you log on, you should test your connection to the host. To do this, click Connection > Connect, or click the Connect/Disconnect toolbar button. Type a user name and password, then press Enter to log on. For a demonstration host, you can use any log on name and password.
  4. After you have made a successful connection, disconnect from the demonstration host by clicking Connection > Disconnect.
  5. Finally, click File > Save As. Type LocalDemo in the File name box, then click Save.

Running the Sample

Follow these steps to run the sample:

  1. Copy the files ReflectionIBM.sbh, ReflectionIBM.sbl, CustomDriverCommand.sbl into the Robot SQABasic path and compile. This is the additional Custom Driver Command implementation for RRAFS to support HLLAPI. Rename and keep the original CustomDriverCommand.sbl if you like.
  2. Create new Robot GUI scripts ReflectionSample_CycleDriver, ReflectionSample_ExportXLTables in Robot, and copy the contents from the attached files and compile.
  3. Create the HourGlass, StatusBar, and LogonMsg VPs in the main script ReflectionSample_CycleDriver.
  4. Copy Excel files, ReflectionSample_HIGH, ReflectionSample_MAP and ReflectionSample_STEP into your project Datapool directory.
  5. Connect to the Reflection for IBM internal sample host.
  6. Run ReflectionSample_CycleDriver.

Conclusion

There are many ways to automate mainframe applications testing using Robot. Pete Jenney and Raymond Gilbert presented some of their experience in the Mainframe Application Testing with Rational Robot article listed in the Resources section following. There are many other ways to manipulate the terminal screen text as well. For example, you can use a copy/paste approach to copy the screen text to a text file and examine the content from there.

Our organization has adopted RRAFS as one of the major platforms for functional test automation. Therefore we always try to comply with the spirit of a framework-based approach while looking into new solutions for mainframe and other applications test automation. This paper shares some of our experience during our exploration. For those who are interested in this area, we also recommend you to try other techniques presented in Application Testing.


Resources


About the author

Jirong Hu is currently working for IBM Rational Canada as a Rational tools consultant, mainly working in the areas of software process, change control, and quality and configuration managerment.

Comments (Undergoing maintenance)



Trademarks  |  My developerWorks terms and conditions

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Rational
ArticleID=85482
ArticleTitle=Using IBM Rational Robot Test Automation Framework Support (RRAFS) to Test Mainframe Applications
publish-date=07052006
author1-email=hujirong888@yahoo.com
author1-email-cc=

My developerWorks community

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Rate a product. Write a review.

Special offers