Flex自動化テスト


自動化テストツールにはQTP,RFTなどがあり,RFTでFlex(SDK version:2.0.1)をテストする手順を紹介する.
RFT(Rational Functional Test)はIBMが開発した自動化テストツールで、web、GUI、consoleをテストすることができます.
前提条件:
1. Flex SDK installed
2. RFT installed
3. jdk installed
4. flex automation support available
Flex Automationソフトウェアがインストールされていない場合は、次の2つのファイルを含む添付ファイルをダウンロードできます.
   automation_agent.swc
   automation_agent_rb.swc
準備:
1.automation_のコピーagent.swcから/Filex SDK 2/frameworks/libsディレクトリの下
2.automation_のコピーagent_rb.swcから/frameworks/locale/en_USディレクトリの下
3.IE[Internet Options]-[Security]-[Local Intranet]を開き、
[Custom Level]をクリックし、セキュリティレベルを[Medium-low]に設定します.
[Initialize and script ActiveX controls not marked as safe for scripting]をEnabledに設定
  
RFTテストFlexはFlex test automation runtime環境を準備する必要があります.
1.Runtimeのswfファイルをhtmlページにネストし、測定されたflexをパラメータで転送する
a.RFTのインストールディレクトリからRuntimeLoaderを見つける.mxml and RuntimeLoadingTest.html
b.RuntimeLoader.のコンパイルmxmlファイル、runtimeサポートに追加:
%FLEX_BUILDER_DIR%\bin\mxmlc.exe -include-libraries+="%FLEX_BUILDER_DIR%\frameworks\libs\automation.swc;%FLEX_BUILDER_DIR%\frameworks\libs\automation_agent.swc;%FLEX_BUILDER_DIR%\frameworks\libs\automation_charts.swc;%IBM_RATIONAL_RFT_INSTALL_DIR%\rft.swc;%IBM_RATIONAL_RFT_INSTALL_DIR%\rftProp.swc"; %1

注意:FLEX_の場合BUILDER_DIRまたはIBM_RATIONAL_RFT_INSTALL_DIRはシステム環境変数に設定されていません.実際のパスに置き換えてください.
上のコードをflexにコピーして保存します.automation.batファイルでコマンドを実行

flex_automation.bat RuntimeLoader.mxml

antスクリプトを使用できます.

    <target name="flexAutomation" depends="initProperties">
        <property name="FLEX_HOME" value="E:/Program Files/Flex_2"/>
        <property name="rftBinDir" value="C:\Program Files\IBM\SDP\FunctionalTester\bin" />
        
        <for param="fileName">
            <path>
                <fileset dir="flex/src">
                    <include name="RuntimeLoader.mxml"/>
                </fileset>
            </path>
            <sequential>
                <mxmlc file="@{filename}" keep-generated-actionscript="true">
                    <source-path path-element="flex/locale"/>
                    <compiler.include-libraries dir="${FLEX_HOME}/frameworks/libs">  
                        <include name="automation.swc"/>  
                        <include name="automation_agent.swc"/>  
                        <include name="automation_charts.swc"/>  
                    </compiler.include-libraries>  
                    <compiler.include-libraries dir="flex/lib">
                        <include name="graphLayout.swc" />
                        <include name="unComponentToolbox.swc" />
                        <include name="PrimitiveIcons.swc" />
                    </compiler.include-libraries>
                    <compiler.include-libraries dir="${rftBinDir}">  
                        <include name="rft.swc"/>  
                        <include name="rftProp.swc"/>  
                    </compiler.include-libraries> 
                </mxmlc>
            </sequential>
        </for>
        <copy todir="D:/" preservelastmodified="yes">
            <fileset dir="flex/src">
                <include name="RuntimeLoader.swf"/>
            </fileset>
        </copy>
    </target>

c.生成したRuntimeLoader.swf、RuntimeLoadingTest.htmlは、テストされたflexファイル(testApp.swf)とともにwebコンテナディレクトリにコピーされます.
d.ウェブサービスを開き、urlに次の文字列を入力します.
   http://localhost/RuntimeLoadingTest.html?automationswfurl=testApp.swf
RFTでFlexオブジェクトを捕まえることができます.
2.測定されたflexコードを再コンパイルし、Runtimeサポートに参加する
a.上記の方法のbステップと同様に、ここでは実行する限り:

flex_automation.bat testApp.mxml

b.testAppを生成する.htmlファイル、中にtestAppがネストされています.swf

 ...

 <object id="myFlex" ... >
    <param name="movie" value="testApp.swf"/>
    ...
    <embed src="testApp.swf" ... >
    </embed>
 </object>
    
 ...

c.testApp.htmlとtestApp.swfをWebコンテナディレクトリにコピー
d.ウェブサービスを開き、urlに次の文字列を入力します.
参照
http://localhost:8080/testApp.htm
注意:
1.準備作業3を行う必要があります.IEのデフォルト設定では、Flex Automation runtimeの実行がブロックされます(安全とマークされていないため)
2.直接入力http://localhost:8080/testApp.swfFlexは表示できますが、テストはできません.
3.第一の方法はFlexコンポーネントを識別するswcをRuntimeLoaderにコンパイルすることである.swfでは、テストされたswfは、これらのswcを追加する必要はありません.
第2のスキームは、テストするswfファイルごとに再コンパイルし、サポートするswcを追加することです.
  
実際の生産環境では、swfファイルが他の場所からデータを受け入れる必要がある場合、第2のスキームが適切であるが、swfファイルが増大し、性能が低下することもある.
4.ここでのテストはFlex SDK 2.0.1に基づいています.他のバージョンの場合は、ネット上の他のドキュメントを検索してください.