久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

怎樣用Ant測試Spring項目(Ant測試自動化--下

 kekokeko 2010-12-10

怎樣用Ant測試Spring項目

 


 


   對于Spring項目,還有另外的講究,。

一、可以運行,但是要設(shè)置Eclipse,以使Eclipse自動往我的    <property name="run.classpath" value="${home.dir}/bin"></property>

中復(fù)制Spring配置文件。

   <?xml version="1.0"?>

<!--

   設(shè)置了路徑以后就正常了

   Eclipse中,,java構(gòu)建路徑.java源:src,test,WebRoot;

     缺省輸出文件夾  為/bin  這個目錄,否則會報Spring的bean未定義錯誤,!

        原因就是因為Spring配置文件無法在classpath中找到,!

-->

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

<!--      chu shi hua , ti gong huan jing bian liang  deng  zhun bei   -->

   <target name="init">

  

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

         

         <property name="run.classpath" value="${home.dir}/bin"></property>

    

       <!--

          <property name="run.classpath" value="${home.dir}/build/classes"></property>

          -->

         <property name="run.srcpath" value="${home.dir}/src"></property>


 


         <property name="test.srcpath" value="${home.dir}/test"></property>

        

         <property name="test.report" value="${home.dir}/report"></property>

          <!--

          <property name="test.config" value="${home.dir}/WebRoot"></property>

           -->

         <property name="lib.dir" value="${home.dir}/lib"/>   


 


       


 


         <path id="compile.path">


 


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

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

                      </fileset>


 


         </path>

     </target>  

<!-- Compilation Classpath

    <path id="compile.classpath">

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

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

       </fileset>

    </path>

  -->     

 

  <!-- Compile ,wei JUnit ti gong .class wen jian.  zai jia shang yu xian ti gong de

     jar zhong de .class  wen jian , ji ke yun xing JUnit. 

       dang ran, hai xu yao junit.jar he ant-junit.jar(huo  optional.jar) he ant.jar zhe 3 ge jar bao de zhi chi

    -->

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


 


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


 


                            classpathref="compile.path"/>


 


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


 


                            classpathref="compile.path"/>


 


         </target>


 


       

<!-- junit renwu, zhi xing junit ce shi  .  bie wang le,classpath ,the classpath to use.

  xu yao zhi ding classpath yuansu ,ta bao kuo compile lu jing,he  bian yi de jie gou classpath

  (bao kuo sheng cheng de suo you .class  wen jian)

 -->

         <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}"/>

                              <!-- 

                              <pathelement path="${test.config}"/>

                              -->

                             <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>

<!-- =============================== all ==================================== -->

  <target name="all" depends="junit" />

</project>


 

 

 


二、不需要借助于Eclipse自動構(gòu)建功能的Ant文件:

<?xml version="1.0"?>

 


 


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

 

<!--      chu shi hua , ti gong huan jing bian liang  deng  zhun bei   -->

 

   <target name="init">

 

  

 

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

 

         

 

         <property name="test.war" value="${home.dir}/build/war"></property>

 

        

 

       <property name="run.classpath" value="${home.dir}/build/war/WEB-INF/classes"></property>

 

       <!--

 

          <property name="run.classpath" value="${home.dir}/build/classes"></property>

 

          -->

 

         <property name="run.srcpath" value="${home.dir}/src"></property>

 


 


         <property name="test.srcpath" value="${home.dir}/test"></property>

 

        

 

         <property name="test.report" value="${home.dir}/report"></property>

 

        

 

          <property name="test.config" value="${home.dir}/WebRoot"></property>

 

        

 

         <property name="lib.dir" value="${home.dir}/lib"/>   

 


 


        <property name="telecom_LDBS.config" value="${test.war}/WEB-INF/classes/config"/>

 


 


         <path id="compile.path">

 


 


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

 

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

 

                       </fileset>

 


 


         </path>

 

     </target>  

 

<!-- Compilation Classpath

 

    <path id="compile.classpath">

 

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

 

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

 

        </fileset>

 

    </path>

 

  -->     

 

 

 

  <!-- Compile ,wei JUnit ti gong .class wen jian.  zai jia shang yu xian ti gong de

 

     jar zhong de .class  wen jian , ji ke yun xing JUnit. 

 

       dang ran, hai xu yao junit.jar he ant-junit.jar(huo  optional.jar) he ant.jar zhe 3 ge jar bao de zhi chi

 

    -->

 

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

 


 


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

 


 


                            classpathref="compile.path"/>

 


 


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

 


 


                            classpathref="compile.path"/>

 


 


         </target>

 


 


   <!-- =============================== war ==================================== -->

 

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

 

    <mkdir dir="${test.war}/WEB-INF"/>

 

    <mkdir dir="${test.war}/WEB-INF/classes/config/db"/>

 

    <mkdir dir="${test.war}/WEB-INF/classes/config/acl"/>

 

    <copy todir="${test.war}">

 

        <fileset dir="${test.config}"  excludes="**/vssver.scc">

 

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

 

             <exclude name="**/vssver.scc"/>

 

             <exclude name="**/build.xml"/>

 

            <exclude name="**/build.properties"/>

 

            <exclude name="**/targets.xml"/>

 

        </fileset>

 

    </copy>

 

   

 

   

 

    <copy todir="${test.war}/WEB-INF/classes/config/db">

 

      <fileset dir="${telecom_LDBS.config}/db">          

 

      </fileset>

 

    </copy>

 

    <copy todir="${test.war}/WEB-INF/classes/config/acl">

 

       <fileset dir="${telecom_LDBS.config}/acl">

 

            <include name="*.xml" />

 

             <exclude name="**/vssver.scc" />

 

       </fileset>

 

    </copy>

 


 


  </target>

 

       

 

<!-- junit renwu, zhi xing junit ce shi  .  bie wang le,classpath ,the classpath to use.

 

  xu yao zhi ding classpath yuansu ,ta bao kuo compile lu jing,he  bian yi de jie gou classpath

 

  (bao kuo sheng cheng de suo you .class  wen jian)

 

 -->

 

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

 


 


                   <tstamp/>

 

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

 

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

 

 

 

                   <junit printsummary="true">

 


 


                            <classpath >

 

                              <pathelement path="${test.war}"/>

 

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

 

                              <!-- 

 

                              <pathelement path="${test.config}"/>

 

                              -->

 

                             <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>

 

<!-- =============================== all ==================================== -->

 

  <target name="all" depends="junit" />

 

</project>

 


 

 

 


這樣,,我手工把Spring等文件復(fù)制到war目錄中,。然后,再將這個目錄也加到Junit任務(wù)的classpath路徑中,。 

也就是說,,現(xiàn)在,classpath中由3部分組成:

1,,jar文件集

2,,.class文件集

3,Spring,、Hibernate等配置文件集,。

實際上,我們也可以進(jìn)一步改進(jìn),。將JUnit任務(wù)和發(fā)布war包的任務(wù)合在一起,。


 

 

 


三、下面就是將JUnit融合進(jìn)原有war包發(fā)布的ant文件后的東東:


 


<?xml version="1.0"?>

 


 


<!-- =================================================================== -->

 

<!-- $Id: build.xml,v 1.3 2004/02/08 09:04:42 cvs Exp $              -->

 

<!-- =================================================================== -->

 


 


<project name="telecom_LDBS" default="all" basedir=".">

 


 


<!-- =============================== init ==================================== -->

 

  <target name="init">

 

    <!-- change this property to use a compiler other than javac. -->

 

    <property name="build.compiler" value="modern"/>

 


 


    <!-- The root directory of the workspace -->

 

    <property name="telecom_LDBS.home" value="."/>

 

    <property name="telecom_LDBS.lib" value="${telecom_LDBS.home}/lib"/>

 

   

 

    <property name="telecom_LDBS.src" value="${telecom_LDBS.home}/src"/>

 

    <!-- The destination directory for the build -->

 

    <property name="telecom_LDBS.build" value="${telecom_LDBS.home}/build"/>

 

    <property name="telecom_LDBS.buildconfigdir" value="${telecom_LDBS.home}/build/config"/>

 

    <property name="telecom_LDBS.buildwardir" value="${telecom_LDBS.home}/build/war"/>

 

    <property name="telecom_LDBS.buildeardir" value="${telecom_LDBS.home}/build/ear"/>

 


 


    <!-- The destination directory for all the compiled classes. -->

 

    <property name="telecom_LDBS.classbindir" value="${telecom_LDBS.build}/classes"/>

 

    <property name="telecom_LDBS.srcdocroot" value="${telecom_LDBS.home}/WebRoot"/>

 

    <property name="telecom_LDBS.config" value="${telecom_LDBS.srcdocroot}/WEB-INF/classes/config"/>

 


 


<!-- junit tina jia-->

 

     <property name="test.report" value="${telecom_LDBS.home}/report"></property>

 

     <property name="test.srcpath" value="${telecom_LDBS.home}/test"></property>

 

 <!--   ^ junit tina jia-->   

 

    

 

    <!-- Compilation Classpath -->

 

    <path id="compile.classpath">

 

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

 

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

 

        </fileset>

 

    </path>

 


 


 

 

    <!-- The destination appServer for War. -->

 

    <property name="tomcat.deployhome" value="D:\java\tomcat\webapps"/>

 

    <property name="tomcat.deploywar" value="${tomcat.deployhome}\telecom_LDBS_ADSL"/>

 


 


  </target>

 


 


  <!-- =============================== compile ==================================== -->

 

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

 

    <echo message="${telecom_LDBS.classpath}" />

 

    <mkdir dir="${telecom_LDBS.classbindir}"/>

 

    <javac srcdir="${telecom_LDBS.src}"

 

           destdir="${telecom_LDBS.classbindir}"

 

           includes="com/**"

 

           debug="yes">

 

    <classpath refid="compile.classpath"/>

 

    </javac>

 


 


    <!-- Convert resource file's character -->

 

    <copy file="${telecom_LDBS.src}/com/telecom/ldbs/common/util/ApplicationResources_ISO.properties"

 

            tofile="${telecom_LDBS.src}/com/telecom/ldbs/common/util/ApplicationResources.properties"/>

 

    <native2ascii encoding="gb2312" src="${telecom_LDBS.src}" dest="${telecom_LDBS.classbindir}"

 

            includes="**/*Resources.properties"/>

 


 


    <copy todir="${telecom_LDBS.classbindir}">

 

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

 

        <include name="**/*_ISO.properties"/>

 

        <include name="**/*Methods.properties"/>

 

      </fileset>

 

    </copy>

 


 


    <copy todir="${telecom_LDBS.classbindir}">

 

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

 

      </fileset>

 

    </copy>

 

  </target>

 


 


 

 


 


   <!-- =============================== war ==================================== -->

 

  <target name="war" depends="init">

 

    <mkdir dir="${telecom_LDBS.buildwardir}/WEB-INF"/>

 

    <mkdir dir="${telecom_LDBS.buildwardir}/WEB-INF/classes/config/db"/>

 

    <mkdir dir="${telecom_LDBS.buildwardir}/WEB-INF/classes/config/acl"/>

 

    <copy todir="${telecom_LDBS.buildwardir}">

 

        <fileset dir="${telecom_LDBS.srcdocroot}"  excludes="**/vssver.scc">

 

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

 

             <exclude name="**/vssver.scc"/>

 

             <exclude name="**/build.xml"/>

 

            <exclude name="**/build.properties"/>

 

            <exclude name="**/targets.xml"/>

 

        </fileset>

 

    </copy>

 

    <copy todir="${telecom_LDBS.buildwardir}/WEB-INF/lib">

 

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

 

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

 

             <exclude name="**/vssver.scc" />

 

            <exclude name="**/servlet.jar" />

 

            <exclude name="**/j2ee.jar" />

 

        </fileset>

 

    </copy>

 

    <copy todir="${telecom_LDBS.buildwardir}/WEB-INF/classes">

 

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

 

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

 

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

 

             <exclude name="**/vssver.scc" />

 

      </fileset>

 

    </copy>

 

    <copy todir="${telecom_LDBS.buildwardir}/WEB-INF/classes">

 

      <fileset dir="${telecom_LDBS.srcdocroot}/WEB-INF/menu">

 

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

 

      </fileset>

 

    </copy>

 

    <copy todir="${telecom_LDBS.buildwardir}/WEB-INF/classes/config/db">

 

      <fileset dir="${telecom_LDBS.config}/db">          

 

      </fileset>

 

    </copy>

 

    <copy todir="${telecom_LDBS.buildwardir}/WEB-INF/classes/config/acl">

 

       <fileset dir="${telecom_LDBS.config}/acl">

 

            <include name="*.xml" />

 

             <exclude name="**/vssver.scc" />

 

       </fileset>

 

    </copy>

 


 


  </target>

 


 

 

 


  <!-- =============================== deploy ==================================== -->

 

  <target name="deploy" depends=" compile, war">

 

    <mkdir dir="${tomcat.deploywar}" />

 


 


    <copy todir="${tomcat.deploywar}">

 

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

 

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

 

         </fileset>

 

    </copy>

 

  </target>

 


 


    <target name="deploy_jsp" depends="init">

 

        <copy todir="${tomcat.deploywar}">

 

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

 

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

 

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

 

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

 

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

 

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

 

             </fileset>

 

        </copy>

 

    </target>

 


 


  <!-- =============================== deploy_all ==================================== -->

 

    <target name="deploy_all" depends="init">

 

        <copy todir="${tomcat.deploywar}">

 

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

 

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

 

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

 

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

 

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

 

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

 

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

 

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

 

             </fileset>

 

        </copy>

 

    </target>

 


 


  <!-- =============================== clean ==================================== -->

 

  <target name="clean" depends="init">

 

    <mkdir dir="${telecom_LDBS.build}" />

 

    <mkdir dir="${tomcat.deploywar}" />

 

   

 

    <delete includeEmptyDirs="true">

 

         <fileset dir="${telecom_LDBS.build}" includes="**/**"/>

 

    </delete>

 

    <delete includeEmptyDirs="true" failonerror="false">

 

         <fileset dir="${tomcat.deployhome}/telecom_LDBS" includes="**/**"/>

 

    </delete>

 

  </target>

 

 

 

 

 

  <!-- junit tina jia-->

 

  <!-- junit renwu, zhi xing junit ce shi  .  bie wang le,classpath ,the classpath to use.

 

  xu yao zhi ding classpath yuansu ,ta bao kuo compile lu jing,he  bian yi de jie gou classpath

 

  (bao kuo sheng cheng de suo you .class  wen jian)

 

 -->

 

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

 


 


                   <tstamp/>

 

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

 

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

 

 

 

                   <junit printsummary="true">

 


 


                            <classpath >

 

                              <pathelement path="${telecom_LDBS.buildwardir}"/>

 

                              <pathelement path="${telecom_LDBS.classbindir}"/>

 

                              <!-- 

 

                              <pathelement path="${test.config}"/>

 

                              -->

 

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

 

                              <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>

 

  <!-- ^ junit tina jia-->

 

  <!-- =============================== all ==================================== -->

 

  <target name="all" depends=" clean, compile, war ,junit"/> 

 

</project>

 


 

 

 


只是添加了幾個目錄,,然后又加上了junit任務(wù)即可,。

 

本文來自CSDN博客,轉(zhuǎn)載請標(biāo)明出處:http://blog.csdn.net/shendl/archive/2005/11/18/532592.aspx

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,,所有內(nèi)容均由用戶發(fā)布,,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式,、誘導(dǎo)購買等信息,,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,,請點擊一鍵舉報,。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多