国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網(wǎng)站 > WEB開發(fā) > 正文

24.10.生成自動(dòng)測(cè)試集

2024-04-27 13:52:37
字體:
供稿:網(wǎng)友
24.10.1. 問題
我想自動(dòng)生成包含所有測(cè)試用例的測(cè)試集。
24.10.2. 解決辦法
使用Antennae TestSuite-generation工具。
24.10.3. 討論
TestCase必須包含進(jìn)TestSuite才可以運(yùn)行。創(chuàng)建新的TestCase并添加到TestSuite已經(jīng)成為一種體力活。為了代替這種手工添加每個(gè)TestCase到TestSuite,你可以讓TestSuite自動(dòng)生成。開源的Antennae項(xiàng)目包含一個(gè)工具自動(dòng)檢測(cè)源代碼目錄和包含的測(cè)試自動(dòng)生成TestSuite。

Antennae 包中的lib 子目錄包含一個(gè)JAR 文件叫arc-flexunit2.jar , 里面有個(gè)類叫com.allurent.flexunit2.framework.AllTestsFileGenerator。當(dāng)AllTestsFileGenerator在源代碼目錄運(yùn)行時(shí),它會(huì)尋找所有命名為Test*.as 或*Test.as并創(chuàng)建包含它們的TestSuite。這個(gè)工具在可以被重新定位的標(biāo)準(zhǔn)輸出上創(chuàng)建TestSuite。生成的TestSuite文件被叫做FlexUnitAllTests。

假設(shè)Antennae被解壓到~/Antennae和C:/Antennae,你可以像下面那樣調(diào)用此工具:
java -cp ~/Antennae/lib/arc-flexunit2.jar
com.allurent.flexunit2.framework.AllTestsFileGenerator
~/FlexCookbook/src/ > ~/FlexCookbook/src/FlexUnitAllTests.as

java -cp C:/Antennae/lib/arc-flexunit2.jar
com.allurent.flexunit2.framework.AllTestsFileGenerator
C:/FlexCookbook/src/ > C:/FlexCookbook/src/FlexUnitAllTests.as
第一個(gè)例子中, ~/Antennae/lib/arc-flexunit2.jar 是JAR 文件的位置。運(yùn)行的類名為com.allurent.flexunit2.framework.AllTestsFileGenerator,~/FlexCookbook/src/是源代碼目錄位置,~/FlexCookbook/src/FlexUnitAllTests.as 是生成文件的位置。

生成的TestSuite文件大概是這樣:
+展開
-ActionScript
package
{
import flexunit.framework.*;
import mx.containers.CanvasTest;
import mx.containers.TileTest;
public class FlexUnitAllTests
{
public static function suite() : TestSuite
{
var testSuite:TestSuite = new TestSuite();
testSuite.addTestSuite(mx.containers.CanvasTest);
testSuite.addTestSuite(mx.containers.TileTest);
return testSuite;
}
}
}

當(dāng)FlexUnit應(yīng)用程序被編譯之前,總是需要自動(dòng)生成FlexUnitAllTests文件(請(qǐng)看Antennae文檔關(guān)于Flex Builder下使用AllTestsFileGenerator工具的更多細(xì)節(jié))

為了代替在主應(yīng)用程序中手動(dòng)構(gòu)建TestSuite,可直接用FlexUnitAllTests類來代替TestSuite運(yùn)行。每次FlexUnitAllTests類被重新生成時(shí),所有包含的測(cè)試都將被重新編譯和運(yùn)行。使用FlexUnitAllTests的FlexUnit應(yīng)用程序如下:
+展開
-XML
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:flexui="flexunit.flexui.*"
creationComplete="handleCreationComplete();">

<mx:Script>
<![CDATA[
import flexunit.framework.TestSuite;
private function handleCreationComplete():void
{
testRunner.test = FlexUnitAllTests.suite();
testRunner.startTest();
}

]]>
</mx:Script>
<flexui:TestRunnerBase id="testRunnerwidth="100%height="100%"/>
</mx:Application>
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 牡丹江市| 宜阳县| 庆阳市| 蓬莱市| 天门市| 天长市| 宝山区| 井陉县| 彰武县| 保康县| 富平县| 三门县| 英吉沙县| 广饶县| 德阳市| 剑河县| 渝北区| 云浮市| 莒南县| 广饶县| 木里| 宜宾市| 进贤县| 清原| 枝江市| 朝阳区| 恩平市| 呼伦贝尔市| 涞水县| 耒阳市| 黄梅县| 延寿县| 邵东县| 竹山县| 太康县| 诸城市| 乐至县| 龙里县| 中宁县| 扶沟县| 安乡县|