Testing Using Rational Robot versus Rational Functional Tester

This article is for Rational Robot users who are wondering how easy it is to switch to Rational Functional Tester. The answer: simple. Using a custom verification point as an example, this article will compare the two products to show you how similar they are to use.

Andreas Franke (FRANKE1@de.ibm.com), Senior IT Specialist, IBM Deutschland GmbH

Andreas Franke is a Senior IT Specialist at IBM Deutschland GmbH. You can reach him at FRANKE1@de.ibm.com.



13 June 2006

Also available in Chinese

Introduction

Often customers who use IBM® Rational® Robot ask how difficult it is to move from Rational Robot to IBM® Rational® Functional Tester (RFT). This article shows you, using a few examples, how easy it is to make the move, and how similar the user experience is. Manual coding can increase the functionality and stability of a test script, so a manual verification point will be the basis for comparing and contrasting Rational Robot and RFT. To show some practical examples, it is necessary to build some logic around this verification point. This logic is arranged in different sections, which are:

  • Read the text Property from the Place Order button (see Figure 1)
  • Open and create a file
  • Write the text Property into this file
  • Open another file and read the contents of this file (expected value=BASELINE)
  • Compare the baseline with the actual result
  • Write a log message

Each of these sections shows the differences for that step between the coding for Rational Robot and that for RFT. In addition, all example test scripts include the same content. The RFT Java™ script example, though, includes additional error handling. It is outside the scope of this article to explain what Rational Robot and RFT are. It will also not address how to record and playback a test script.


Installation and Configuration

You should have the following installed:

  • Rational Robot
  • RFT Java
  • RFT VB .NET
  • Java ClassicsB Application

Using Notepad (or a similar plain text editor), create a file named Expected.txt, with the content Place Orders, and save it under C:\. This will serve as the baseline file mentioned previously. To configure your environment for this example, follow these steps:

  1. After installing Rational Robot, run the Java test-enabler by clicking Start > Programs > Rational Software > Rational Test > Java Enabler
  2. After the installation of Rational Functional Tester, enable the environment and enable the application for testing. To do so, in the RFT Menu click Configure > Enable Environment for Testing and Configure > Configure Application for Testing
  3. The best way to use the example code is to capture an empty script with the name read_and_write, then copy and replace it with the example script.
  4. Open the object-map and insert the Place Order button, as shown in Figure 1.
Figure 1. Place Order button
Place Order button

Create a manual verification point

Figure 2 illustrates the coding of the manual verification point in each product.

Figure 2. Coding the verification point
Coding the verification point

In the Rational Robot SQA Basic command, you need to write the object recognition parameter inside the script, which necessitates some additional thinking on your part. Then, the value from the Property text will assign to the string variable MyText. Generally, it is possible to assign all recognisable properties to a variable. The object in the RFT script points to the object inside the object map. To enter the code, it is very helpful to use the editor functionality. In this case, enter the first two characters and press strg and space. A list with valid methods appears, and you can make a selection, fast and easy.

In the Java and VB .NET scripts, you can read the verification point directly from left to right. This increases the ease with which you can understand the content. For example: the content of the String variable strProperty_Text is equal to something that has to do with the object placeOrder. The relationship between the object and the method is placed after the object.

In this example, the method is getProperty. To specify the Property, you need to enter the type of Property ("Text"). So the srtProperty_text variable gets the property value of the text (Place Order) from the placeOrder object.


Create and open a file

In this section, the script will open the File c:\Buton_Text.txt and save the Property value Text, as shown in figure 3.

Figure 3. Script to open a file and save the Property text
Script to open a file and save the Property text

With this example it should be becoming more clear that the commands and functionality to create this kind of verification method are very similar between Rational Robot and the RFT specifications. In each product, it is possible to create, open, and write to a file with three lines of code.

Open and read from a file

Figure 4 shows you how to open the File c:\Expected.txt and write the content in a String.

Figure 4. Opening and reading from a file
Opening and reading from a file

Compare data

The scripts in figure 5 compare two String variables and generate a log message.

Figure 5. Comparing data
Comparing data

As you can see, the coding differences between the products are minimal, with the exception of a few development-environment specifics. The effort to implement this kind of coding is the same whether you’re using Rational Robot or RFT. Furthermore, if you know the SQA-Basic command it is very easy -- with help from the RFT editor (enter first characters and press Strg and Space) -- to implement additional functionality in the test script.

Listings

Listing 1. The Rational Robot script: SQA Basic
Sub Main
    Dim Result As Integer
    Dim MyText as Variant
    Dim strFilename as String
    Dim intFileNum as Integer
    Dim strZeile as String
    Dim strLine as string
    strFileName= "c:\Button_Text"
    intFileNum = FreeFile()
    'Script Name: read_and_write
    
 
    StartJavaApplication Class:=
    """C:\Program Files\IBM\Rational\SDP\6.0\FTSamples\ClassicsJavaB.jar""", 
    JvmKey:="Java", JvmOpts:="-jar"
    
    Window SetContext, "Caption=ClassicsCD", ""
  
    Result = SQAGetPropertyAsString("Type=PushButton;Name=Place Order", "Text", MyText)
    Open strFilename For Output AS # intFileNum
    Print #intFileNum,MyText    
    ' The Value of the Pushbutton property text will be save in c:\Button_Text 
    Close # intFileNum
   
    'Open the file to read the content 
     If strLine = myText then
        SQALogMessage sqaPass, "The Button Text is correct: " + MyText, ""
            else
            SQALogMessage sqaFail, " Expected Pusch-button-Text = " + strLine, 
            "The Button Text is incorrect"
     end if
End Sub
Listing 2. The RFT script: Java
import resources.read_and_writeHelper;
import java.io.*;
import javax.swing.JOptionPane;

public class read_and_write extends read_and_writeHelper
{
	/* Before you can use this script you must create a c:\Expected.txt file
	 * Write the value inside this file and save it.
	 * Description   : Functional Test Script
	 * @author Andreas Franke
	public void testMain(Object[] args)
	 {
	    FileWriter f1;
	    BufferedReader f2;
		String line;
		startApp("ClassicsJavaB");  
		String strProperty_Text=(String)placeOrder().getProperty("Text");
// Read the property Text from the Pushbutton
    try 
	    {
		 f1 = new FileWriter("c:\\Button_Text.txt");    
		 // create a an outputfile
	               f1.write(strProperty_Text);		
	     // write the result from strProperty_Text in this file
	               f1.close();
	    } 
	    catch (IOException e) 
	    {
	        System.out.println("ERROR to create the folder");
	        logTestResult("ERROR to create the folder", false); 
	        // Write an Error-message in the tes-tmanager- 
    log
	    }
	     try 
	   {
		  f2 = new BufferedReader(new FileReader("c:\\Expected.txt"));
		  while ((line = f2.readLine()) != null)
		           {
		             if (line.equalsIgnoreCase(strProperty_Text))
		       	       {
		       	        logTestResult("The Button Text is correct", true);
		       	       } 
		       	    		else 
		       	    		{
		       	    		logTestResult("The Button Text is incorrect ", false,
		       	    		"Expected '"+line+"' but found '"+strProperty_Text+"'");
		       	    		JOptionPane.showMessageDialog(null,line,"The Button Text is
 incorrect",JOptionPane.INFORMATION_MESSAGE);
		       	    		}
		           	}
		      f2.close();
		     } 
		 	 catch (IOException e) 
		 	 {
		       System.out.println("Can`t find File");
		       logTestResult("Can`t find File", false);
		     }
	}
}
Listing 3. The Rational Functional Tester script: VB .NET
#Region " Script Header "
' Functional Test Script
' author Administrator
Imports Microsoft.VisualBasic
Imports Rational.Test.Ft
Imports Rational.Test.Ft.Object.Interfaces

Public Class read_and_write 
    Inherits read_and_writeHelper

    'Script Name   : read_and_write

     'author Andreas Franke

    Public Function TestMain(ByVal args() As Object)
        StartApp("ClassicsJavaB")
        
        ' Frame: ClassicsCD
        REM PlaceOrder().Click()
        Dim strFilename As String = "c:\Button_Text"
        Dim strExpected As String = "c:\Expected.txt"
        Dim strProperty_text As String
        Dim intFileNum As Integer
        Dim strLine As String
        
        intFileNum = FreeFile()

        strProperty_text = PlaceOrder.GetProperty("Text")
        MsgBox
        (strProperty_text, MsgBoxStyle.Information, "The Text on the Pushbutton is")
        FileOpen(intFileNum, strFilename, OpenMode.Output)

Print(intFileNum, strProperty_text)   
' The Value of the Pushbutton property text will be save in 
   'c:\Button_Text 
        FileClose(intFileNum)
        FileOpen(intFileNum, strExpected, OpenMode.Input)
        Input(intFileNum, strLine)
  If strProperty_text = strLine Then
    LogTestResult
    ("The Pushbutton Text is correct", True, "Expected Text = Actual Text")
  Else
    LogTestResult
    ("The Pushbutton Text is incorrect!! Expected Text is :
    " + strLine, False, "but found the actual Text : " + strProperty_text)
    MsgBox
    (strProperty_text, MsgBoxStyle.Critical, "The Curent Text is not the expected Text")
End If

End Function
End Class

Resources

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into Rational software on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Rational
ArticleID=127030
ArticleTitle=Testing Using Rational Robot versus Rational Functional Tester
publish-date=06132006