国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
用Ant自動(dòng)測試JUnit(Ant測試自動(dòng)化--上)

                      Ant自動(dòng)測試JUnit

 

 

 

   經(jīng)過痛苦的N次嘗試,終于,我成功的運(yùn)行了Ant驅(qū)動(dòng)的JUnit!

一、問題一  支持ANT<junit>任務(wù)所需的jar包的配置。

Note: This task depends on external libraries not included in the Ant distribution. See Library Dependencies for more information.

 

注意:JUnit這個(gè)人物依賴于可選的庫,不包括在標(biāo)準(zhǔn)ant.jar中。

 

Note: You must have junit.jar and the class files for the <junit> task in the same classpath. You can do one of:

 

注意:你必須擁有junit.jar,并且這個(gè)類文件必須在同一個(gè)ant路徑下

 

  1. Put both junit.jar and the optional tasks jar file in ANT_HOME/lib.

     

1,junit.jar和可選任務(wù)jar(optional.jar) 文件放進(jìn)ANT_HOME/lib目錄中。  環(huán)境變量ANT_HOME = **\ant   這樣的目錄。

 

  1. Do not put either in ANT_HOME/lib, and instead include their locations in your CLASSPATH environment variable.

     

2,如果不把junit.jar和可選任務(wù)jar(optional.jar) 文件放進(jìn)ANT_HOME/lib目錄中,那么可以這樣做:  把這兩個(gè)jar文件的絕對(duì)路徑(包括文件名)寫進(jìn)你的系統(tǒng)環(huán)境變量CLASSPATH中。

 

  1. Do neither of the above, and instead, specify their locations using a <classpath> element in the build file. See the FAQ for details.

     

   3,如果你不想做上面那2個(gè)辦法,那么,你可以這樣:

   在構(gòu)造文件ant中,使用<classpath>元素,指定junit.jar和可選任務(wù)jar(optional.jar) 文件的位置。

 

 

下面是成功的例子:

 

 

<?xml version="1.0"?>

 

<project name="project" default="junit">

 

         <property name="run.classpath" value="bin"></property>

 

         <property name="run.srcpath" value="src"></property>

 

         <property name="test.srcpath" value="test"></property>

        

         <property name="test.report" value="report"></property>

        

         <property name="lib.dir" value="lib"/>   

 

       

 

         <path id="compile.path">

 

                  <fileset dir="${lib.dir}">

           <include name="**/*.jar"/>

       </fileset>

 

         </path>

       

<!-- Compilation Classpath

    <path id="compile.classpath">

       <fileset dir="${telecom_LDBS.lib}">

           <include name="**/*.jar"/>

       </fileset>

    </path>

  -->     

 

         <target name="compile">

 

                   <javac destdir="${run.classpath}" srcdir="${run.srcpath}"

 

                            classpathref="compile.path"/>

 

                   <javac destdir="${run.classpath}" srcdir="${test.srcpath}"

 

                            classpathref="compile.path"/>

 

         </target>

 

       

 

         <target name="junit" depends="compile">

 

                   <tstamp/>

                <mkdir dir="${test.report}"/>

                <mkdir dir="${test.report}/framework-${DSTAMP}-${TSTAMP}"/>

 

                   <junit printsummary="true">

 

                            <classpath >

                              <pathelement path="${run.classpath}"/>

                           

                             <fileset dir="${lib.dir}">

                             <include name="**/*.jar"/>

                            </fileset>

 

                            

                            </classpath>

                           

                           

                        <!--

                            <test name="Ldbs1AdslSectionBaseinfoModelServiceTest"></test>

                         -->

    <formatter type="plain"/>

         <!-- she zhi yao ce shi de wen jian ji he .-->

         <batchtest fork="yes" todir="${test.report}/framework-${DSTAMP}-${TSTAMP}">

         <fileset dir="${test.srcpath}">

             <include name="**/*Test.java"/>

            

         </fileset>

         </batchtest>

 

                   </junit>

 

         </target>

 

</project>

 

 

 

上面這個(gè)例子,可以在cmd命令行中運(yùn)行。

如果要直接在Eclipse中運(yùn)行,則需要改變ant的設(shè)置。

使用eclipse可以按照一下步驟加入:

 

Windows-Preference-Ant-Runtime-Ant Home Entries

 

窗口首選項(xiàng)ant運(yùn)行時(shí)類路徑Ant主目錄條目,然后添加外部jar。  主要添加我們ANT_HOME中的junit.jar這個(gè)文件即可。 實(shí)際不需要optional.jar這個(gè)文件。

因?yàn)椋?span lang="EN-US">org.apache.ant_1.6.2\lib\ant-junit.jar這個(gè)文件,就是一個(gè)AntJUnit任務(wù)可選項(xiàng)的擴(kuò)展.jar文件,現(xiàn)在缺的只是ANT可以找到的JUnitjar文件。   因?yàn)椋?span lang="EN-US">Ant類似于SpringFramework,它托管管理了JUnit,但是實(shí)際功能還是委派給JUnit.jar來實(shí)現(xiàn)的!

 

 

二、問題二  JUnit任務(wù)的classpath支持類路徑的設(shè)置的問題

   這也是一個(gè)錯(cuò)誤點(diǎn)!

示例中是:

<junit printsummary="true">

 

 

                            <classpath>

 

                              <pathelement path="${run.classpath}"/>

 

                            

 

                             <fileset dir="${lib.dir}">

 

                              <include name="**/*.jar"/>

 

                             </fileset>

 

 

                            

 

                            </classpath>

 

其中

 

<property name="run.classpath" value="bin"></property>

<property name="lib.dir" value="lib"/> 

實(shí)際上,這就是我們在  <junit〉任務(wù)下,   我們使用了編譯后的.class文件的目錄,還有編譯所需的jar包所在的目錄。  缺一不可!  否則一定會(huì)報(bào)ClassNotFoundException類未找到異常!

 

因?yàn)椋?span lang="EN-US">JUnit任務(wù),實(shí)際就是為我們運(yùn)行Test類,而不僅僅是想我們的發(fā)布Ant文件那樣僅僅是javac  編譯,只需要編譯所需的Jar包。

我們還需要像java任務(wù)那樣運(yùn)行.class文件。 所以必須包括編譯后的.class文件。

 

 

OK!搞定這兩個(gè)問題后,我們就可以順利地自動(dòng)批量執(zhí)行JUnit測試了!

 



Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=532587


[收藏到我的網(wǎng)摘]   良少shendl發(fā)表于 2005年11月18日 21:34:00

相關(guān)文章:
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
用Ant編譯、junit測試、生成測試報(bào)告、最終自動(dòng)發(fā)mail
無所不能的“螞蟻”--Ant(一)(二)(三)(四)
java-在通過Ant進(jìn)行Junit測試期間無法在Jar中找到屬性文件
怎樣用Ant測試Spring項(xiàng)目(Ant測試自動(dòng)化--下
build-example.xml(ant+junit測試報(bào)告)
Ant學(xué)習(xí)指南
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服