Flex-flexunit-integration
提供:Dev Guides
Flex-FlexUnit統合
Flash Builder 4には、Flex開発サイクルでのFlexUnit統合に対する優れた組み込みサポートがあります。
テストケースクラスを作成する
Flash Builderのテストクラス作成ウィザードを使用して、テストケースクラスを作成できます。 この記事で説明するように、Flash Builderを使用すると、テストケースを簡単に実行できます。
Flash Builderを使用してテストケースクラスを作成するには、*ファイル>新規>テストケースクラス*をクリックします。 以下に示すように詳細を入力します。
Flash Builderは、次のTestClass1 ..をファイルとして作成します。
FlexUnit統合の例
ここで、FlexアプリケーションでFlexUnit統合をテストする手順に従います-
Step | Description |
---|---|
1 | Create a project with a name HelloWorld under a package com.finddevguides.client as explained in the Flex - Create Application chapter. |
2 | Modify HelloWorld.mxml as explained below. Keep rest of the files unchanged. |
3 | Create TestClass1.as test case as described above and Modify TestClass1.as as explained below. |
4 | Compile and run the application to make sure business logic is working as per the requirements. |
以下は、変更されたファイル src/com.finddevguides/client/TestClass1.as の内容です。
以下は、変更されたmxmlファイル src/com.finddevguides/HelloWorld.mxml の内容です。
すべての変更が完了したら、link:/flex/flex_create_application [Flex-アプリケーションの作成]の章で行ったように、通常モードでコンパイルしてみましょう。
テストケースの実行
パッケージエクスプローラーでTestClass1を右クリックし、[実行]> [FlexUnitテスト]を選択します。 Flash Builderのテストウィンドウに次の出力が表示されます。
Flash Builderでは、ブラウザーにテスト結果も表示されます。