熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Java開源技術 >> 正文

Ant+Cactus+Tomcat5.5容器內單元測試[4]

2022-06-13   來源: Java開源技術 

    RunServerTests是通過直接啟動容器服務起來運行測試因此速度稍慢且配置較麻煩但能測試各種資源

    <target name=test depends=testprepare
    description=Run tests on Tomcat >
    <! Start the servlet engine wait for it to be started run the
    unit tests stop the servlet engine wait for it to be stopped
    The servlet engine is stopped if the tests fail for any reason >
    <! 是服務器的端口號${projectname}cactified是項目的路徑和上一步的cactifywar 的destfile相對應 >
    <runservertests
    testURL=http://localhost:/${projectname}cactified/ServletRedirector?Cactus_Service=RUN_TEST
    startTarget=_StartTomcat
    stopTarget=_StopTomcat
    testTarget=_Test/>
    </target>
    <! _Test就是一個普通的junit任務 >
    <target name=_Test>
    <junit printsummary=yes fork=yes>
    <classpath>
    <path refid=projectclasspath/>
    <pathelement location=${targetclassesjavadir}/>
    <pathelement location=${targetclassestestdir}/>
    </classpath>
    <formatter type=brief usefile=false/>
    <formatter type=xml/>
    <batchtest>
    <fileset dir=${srctestdir}>
    <! Due to some Cactus synchronization bug the unit tests need
    to run before the sample tests >
    <include name=**/Test*java/>
    <exclude name=**/Test*Alljava/>
    </fileset>
    </batchtest>
    </junit>
    </target>

[]  []  []  []  


From:http://tw.wingwit.com/Article/program/Java/ky/201311/29281.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.