integration of Ant&JUnit

          Posted on 2008-03-07 14:29 Robert Su 閱讀(174) 評論(0)  編輯  收藏

           

          <?xml version="1.0" encoding="utf-8"?>
          <project name="test" default="test" basedir=".">

                 
          <!--配置基本屬性-->

                 
          <property name="src" value="src"/>
                 
          <property name="build" value="build"/>
                 
          <property name="lib" value="lib" />
                 
          <property name="dist" value="dist"/>
                 
          <property name="classpath" location="${build}"/>

                 
          <!--配置測試報告的屬性-->

                 
          <property name="report"   value="report"/>
                 
          <property name="report.xml"  value="${report}/junit/xml"/>
                 
          <property name="report.html" value="${report}/junit/html"/>

                  
          <path id="classpath.run">
                        
          <pathelement path="${classpath}"/>
                        
          <fileset dir="${lib}">
                               
          <include name="*.jar"/>
                        
          </fileset>
                 
          </path>

                
          <!--配置測試時classpath-->
                 
          <path id="classpath.test">
                        
          <path refid="classpath.run"/>
                        
          <path location="${dist}/lib/test-${DSTAMP}.jar"/>
                 
          </path>

                 
          <!--任務初始化-->

                 
          <target name="init" >
                        
          <tstamp/>
                        
          <delete dir="${build}"/>
                        
          <delete dir="${report}"/>
                        
          <delete dir="${dist}"/>
                        
          <mkdir dir="${build}"/>
                 
          </target>

                 
          <!--配置編譯任務-->

                 
          <target name="compile" depends="init">
                        
          <javac srcdir="${src}" destdir="${build}">
                        
          <classpath refid="classpath.run" />
                        
          </javac>
                
                 
          </target>
                 
          <echo>Build into ${dest.dir}, successfully.</echo>

                 
          <!--配置打包任務-->
                 
          <target name="dist" depends="compile">
                        
          <mkdir dir="${dist}/lib"/>
                        
          <jar jarfile="${dist}/lib/test-${DSTAMP}.jar" basedir="${build}"/>
                 
          </target>

                 
          <!--配置運行任務-->
                 
          <target name="run" depends="compile, dist">
                   
          <java classname="com.test.HelloWorldTest">
                       
          <classpath>
                               
          <path refid="classpath.run"/>
                        
          </classpath>
                   
          </java>
                 
          </target>
               

                 
          <!--配置JUnit測試,打印測試結果-->
                 
          <target name="test" depends="compile, dist">

                        
          <mkdir dir="${report.xml}"/>
                        
          <mkdir dir="${report.html}"/>
                        
          <junit printsummary="yes" haltonfailure="no">
                               
          <classpath refid="classpath.run"/>
                               
          <formatter type="xml"/>
                               
          <batchtest fork="yes" todir="${report.xml}">
                                      
          <fileset dir="${src}" includes="**/*test.java"/>
                               
          </batchtest>
                        
          </junit>
                     

                        
          <junitreport todir="${report.html}">
                               
          <fileset dir="${report.xml}">
                                      
          <include name="*.xml"/>
                               
          </fileset>
                               
          <report format="frames" todir="${report.html}"/>
                        
          </junitreport>
                     
          <echo>JUnit Success!</echo>
                 
          </target>
              

          </project>

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          posts - 103, comments - 104, trackbacks - 0, articles - 5

          Copyright © Robert Su

          主站蜘蛛池模板: 保山市| 家居| 工布江达县| 新建县| 射阳县| 天祝| 凤凰县| 赤峰市| 中牟县| 湘潭市| 金川县| 察哈| 天镇县| 宁武县| 濉溪县| 嘉荫县| 巴林左旗| 漠河县| 黄浦区| 观塘区| 祁连县| 水富县| 吉安县| 乌拉特前旗| 青州市| 油尖旺区| 石河子市| 马尔康县| 新密市| 尉犁县| 泸溪县| 娱乐| 新兴县| 台南县| 双城市| 江西省| 鄂尔多斯市| 方城县| 长沙县| 湘阴县| 大埔县|