ANT unit tests and Jacoco coverage reports generate and submit reports Sonarqube

Source: Internet
Author: User
Ant
<?xml version= "1.0" encoding= "UTF-8"?> <project name= "Baby-console" default= "War file" basedir= "..." xmlns: jacoco= "Antlib:org.jacoco.ant" > <taskdef uri= "antlib:org.jacoco.ant" resource= "Org/jacoco/ant/antlib.xml" > <classpath path= "${basedir}/lib_coverage/jacocoant.jar" > </classpath> </taskdef&gt
    ; <property name= "Warfilename" value= "Baby-console.war" > </property> <!--load Variables--<propert Y file= "build.properties" description= "Properties"/> <!--load version--<property file= "version.properties "description=" ver_properties "/> <path id=" Project.lib "> <fileset dir=" ${basedir}/webcontent/web- Inf/lib "> <include name=" **/*.jar "/> </fileset> </path> <path id=" Pro
        Vided.lib "> <fileset dir=" ${basedir}/lib_provided "> <include name=" **/*.jar "/> </fileset> </path&Gt 
        <path id= "Test.lib" > <fileset dir= "${basedir}/lib_test" > <include name= "**/*.jar"/> </fileset> </path> <!--Add File in-<path id= "Config.file" > <files
    ET dir= "${basedir}/config" > <include name= "**/*.*"/> </fileset> </path> <target name= "clean" > <delete dir= "${basedir}/build/build"/> <mkdir dir= "${basedir}/build/ Build "/> <mkdir dir=" ${basedir}/build/build/classes "/> <mkdir dir=" ${basedir}/build/build/te Stclasses "/> <mkdir dir=" ${basedir}/build/build/utreport "/> <mkdir dir=" ${basedir}/build/bui Ld/utcoveragereport "/> </target> <target name=" compile "depends=" clean "> <javac source= "1.6" target= "1.6" srcdir= "${basedir}/src" destdir= "${basedir}/build/build/classes" Includeantruntime= "false" debug = "On" > &Lt;compilerarg line= "-encoding UTF-8"/> <classpath refid= "Project.lib"/> <classpath
                Refid= "Provided.lib"/> <classpath refid= "Config.file"/> <classpath> <pathelement location= "${basedir}/config"/> </classpath> </javac> </targ 
            et> <target name= "copy config" depends= "compile" > <copy todir= "${basedir}/build/build/classes" > <fileset dir= "${basedir}/config"/> </copy> </target> <target name= "un It test compile "depends=" copy config "> <javac source=" 1.6 "target=" 1.6 "srcdir=" ${basedir}/test "destdir=" $ {basedir}/build/build/testclasses "includeantruntime=" false "debug=" on "> <compilerarg line="-encoding UT
            F-8 "/> <classpath refid=" project.lib "/> <classpath refid=" Provided.lib "/> <classpath refId= "Test.lib"/> <classpath> <pathelement location= "${basedir}/build/build/classes "/> </classpath> <include name=" **/*ut.java "/> <include name=" **/* Test.java "/> </javac> </target> <target name=" unit Test junit Report "depends=" unit tes T compile "> <junit printsummary=" on "fork=" true "showoutput=" true "> <classpath refid=" proj
            Ect.lib "/> <classpath refid=" provided.lib "/> <classpath refid=" Test.lib "/> <classpath> <pathelement location= "${basedir}/build/build/classes"/> </ classpath> <classpath> <pathelement location= "${basedir}/build/build/testclasses" /> </classpath> <formatter type= "xml"/> <batchtest todir= "${basedir }/build/build/utreport "&Gt
                <fileset dir= "${basedir}/build/build/testclasses" > <include name= "**/*ut*.*"/> </fileset> </batchtest> </junit> <junitreport todir= "${basedir}/bui Ld/build/utreport "> <fileset dir=" ${basedir}/build/build/utreport "> <include name= "Ut-*.xml"/> </fileset> <report format= "frames" todir= "${basedir}/build/build/utrepor
        T "/> </junitreport> </target> <target name=" war file "depends=" copy config "> <delete file= "${basedir}/baby-console.war"/> <war destfile= "${basedir}/${warfilename}" webxml= "${basedi R}/webcontent/web-inf/web.xml "> <fileset dir=" ${basedir}/webcontent "> <include nam
      E= "**/**.*"/> <exclude name= "**/*.jar"/> <exclude name= "**/*.class"/>      </fileset> <lib dir= "${basedir}/webcontent/web-inf/lib"/> <classes dir= "${b Asedir}/build/build/classes "/> </war> </target> <target name=" Test War file "Depends=" Unit Test JUnit Report "> <delete file=" ${basedir}/baby-console.war "/> <war destfile=" ${based Ir}/${warfilename} "webxml=" ${basedir}/webcontent/web-inf/web.xml "> <fileset dir=" ${basedir}/WebContent " > <include name= "**/**.*"/> <exclude name= "**/*.jar"/> &L T;exclude name= "**/*.class"/> </fileset> <lib dir= "${basedir}/webcontent/web-inf/lib "/> <lib dir=" ${basedir}/lib_test "/> <classes dir=" ${basedir}/build/build/classes "/&
            Gt <classes dir= "${basedir}/build/build/testclasses"/> </war> </target> <target name= "u T CoveraGE "> <jacoco:coverage destfile=" ${basedir}/build/jacocout.exec "> <junit haltonfailure=" fal Se "fork=" true "printsummary=" true "> <classpath refid=" project.lib "> </classpa th> <classpath refid= "Provided.lib" > </classpath> <class Path refid= "Test.lib" > </classpath> <classpath> &LT;PA Thelement location= "${basedir}/build/build/classes"/> </classpath> <classpath > <pathelement location= "${basedir}/build/build/testclasses"/> </classpat h> <formatter type= "xml"/> <batchtest todir= "${basedir}/build/build/utcoverag EReport "> <fileset dir=" ${basedir}/build/build/testclasses "> <incl Ude name= "**/*ut.class"/> </fileset> </batchtest> </junit> </jaco co:coverage> </target> <target name= "UT coverage report" depends= "UT coverage" > <jacoco
            :report> <executiondata> <file file= "${basedir}/build/jacocout.exec"/> </executiondata> <structure name= "unit Test coverage Rate Report" > &LT;CLASSF
                iles> <fileset dir= "${basedir}/build/build/classes"/> </classfiles>
                <sourcefiles encoding= "UTF-8" > <fileset dir= "${basedir}/src"/> </sourcefiles> </structure> 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.