對比使用 Rational Robot 和 Rational Functional Tester 進行測試

發表于:2007-05-24來源:作者:點擊數: 標簽:rationalFunctionarobot對比使用
本文是為那些疑惑轉換到 Rational Functional Tester 是否真的那么容易的 Rational Robot 的用戶準備的。答案是:簡單。利用定制的驗證點作為實例,本文將對比這兩種產品,向您展示它們的使用是多么相似。 引言 使用 IBM Rational Robot 的客戶常常問,從 Rat
本文是為那些疑惑轉換到 Rational Functional Tester 是否真的那么容易的 Rational Robot 的用戶準備的。答案是:簡單。利用定制的驗證點作為實例,本文將對比這兩種產品,向您展示它們的使用是多么相似。

引言

使用 IBM® Rational® Robot 的客戶常常問,從 Rational Robot 遷移到 IBM® Rational® Functional Tester (RFT) 上有多難。本文使用了一些實例來告訴您進行遷移是多么容易,并且用戶的使用經驗是多么相似。人工編碼可以增加測試腳本的功能和穩定性,所以人工驗證點將是比較和對比 Rational Robot 和 RFT 的基礎。要介紹一些實際的實例,就有必要在此驗證點周圍建立某種邏輯。該邏輯安排在不同的部分中:

  • 讀取 Place Order 按鈕的文本屬性(參見圖 1)
  • 打開并創建文件
  • 將文本屬性寫入該文件
  • 打開另一個文件,并讀取該文件的內容(期望值=BASELINE)
  • 將基線與實際結果比較
  • 撰寫一條日志消息

每一個部分都顯示出為 Rational Robot 和 RFT 編碼的區別。此外,所有的實例測試腳本包含同樣的內容。盡管 RFT Java™ 腳本實例包含額外的錯誤處理。解釋 Rational Robot 和 RFT 是什么已超出本文的范圍。本文也不介紹如何記錄并回放測試腳本。





回頁首


安裝與配置

您應該安裝以下內容:

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

使用記事本(或者類似的純文本編輯器),創建一個名為 Expected.txt 的文件,內容是Place Orders,并且將其保存在 C:\ 之下。其將作為之前提到的基線文件。要為此實例配置您的環境,按照以下步驟:

  1. 在安裝完 Rational Robot 之后,運行 Java 測試啟動器,單擊 Start > Programs > Rational Software > Rational Test > Java Enabler
  2. 在安裝完 Rational Functional Tester 之后,啟動環境并啟動用于測試的應用程序。要做到這些,在 RFT 菜單上單擊Configure > Enable Environment for Testing and Configure > Configure Application for Testing
  3. 使用該實例代碼的最佳途徑是獲取一個名為 read_and_write 的空腳本,復制實例腳本來替代它。
  4. 打開對象映射并插入 Place Order 按鈕,如圖 1 所示。

圖 1. Place Order 按鈕
Place Order 按鈕




回頁首


創建一個人工驗證點

圖 2 例舉了在每個產品中的人工驗證點編碼。


圖 2. 對驗證點編碼
對驗證點編碼

Rational Robot SQA Basic 命令中,您需要在腳本中撰寫對象識別參數,這需要對您的部分進行額外的考慮。然后,將來自屬性(Property)文本的值分配給字符串變量 MyText。一般來說,將所有可識別屬性分配給一個變量是可能的。RFT 腳本中的對象指向對象映射中的對象。要輸入代碼,使用編輯器功能是非常有幫助的。在這種情況下,輸入前兩個字符并按下 strg 和 space 鍵。一個有效方法的列表出現了,您可以快速簡單地進行選擇。

在 Java 和 VB .NET 腳本中,您可以直接從左到右閱讀驗證點。這使您更容易理解其內容。例如:String 變量 strProperty_Text 的內容等于與對象 placeOrder 有關的內容。對象和方法之間的關系位于對象之后。

在此實例中,方法為 getProperty。要指定屬性,您需要輸入屬性的類型(“Text”)。這樣 srtProperty_text 變量從placeOrder 對象那里獲得了文本(Place Order)的屬性值。





回頁首


創建并打開文件

在此部分中,腳本將打開文件 c:\Buton_Text.txt 并保存屬性值文本,如圖 3 所示。


圖 3. 腳本打開文件并保存屬性文本
腳本打開文件并保存屬性文本

通過此實例,應該更加清楚的是,在 Rational Robot 和 RFT 中,創建此類驗證方法的命令和功能是類似的。在每個產品中,用三行代碼創建、打開并撰寫文件都是可能的。

打開并閱讀文件

圖 4 顯示如何打開文件 c:\Expected.txt 并在 String 中書寫內容。
圖 4. 打開并閱讀文件
打開并閱讀文件

比較數據

圖 5 中的腳本比較了兩個 String 變量并生成了一個日志消息。
圖 5. 比較數據
比較數據

如您所見,除了一些開發環境的細節,兩個產品之間的編碼差別是極小的。不論您使用 Rational Robot 或是 RFT,實現此類編碼的工作是一樣的。此外,如果您知道SQA-Basic 命令,那么在測試腳本中實現額外的功能 —— 利用 RFT 編輯器(輸入開頭字符并按下 Strg 和 Space 鍵)的幫助—— 是很容易的。

清單


清單 1. Rational Robot 腳本: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
            


清單 2. RFT 腳本: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);
            }
            }
            }
            


清單 3. Rational Functional Tester 腳本: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
            

原文轉自:http://www.anti-gravitydesign.com

国产97人人超碰caoprom_尤物国产在线一区手机播放_精品国产一区二区三_色天使久久综合给合久久97