Continuous Integration 4---Unit test solution

Source: Internet
Author: User

    • Automated unit testing can be done using MAVEN or directly with Ant, because Maven is not used in the project and we use Ant

    • Build.xml of unit tests are posted below
<?xml version= "1.0"?> <!--============================================= Auto unittest task ================ ==========================--<project name= "Auto unittest task" default= "JUnit and Report" Basedir= "." > <property name= "output folder" value= "Back-end/sztbservice/out/war_exploded/web-inf/classes"/>< Property name= ' Report folder ' value= "Report"/> <property name= "Build.testcase.dir" value= "${output folder}"/ ><path id= "Ref-lib" > <pathelement location= "${build.testcase.dir}"/><fileset dir= "back-end/ Sztbservice/out/war_exploded/web-inf/lib "> <include name=" *.jar "/> </fileset> <fileset dir=" Back-end/sztbservice/lib "> <include name=" *.jar "/> </fileset></path><target name=" Test init "> <mkdir dir=" ${report folder} "/></target><!--======================================== Target: Auto Test all test case and Output report file =====================================--<taRget name= "JUnit and Report" depends= "Test init" > <junit printsummary= "on" fork= "true" showoutput= "true" > < Classpath refid= "Ref-lib"/><formatter type= "xml"/> <batchtest todir= "${report folder}" > <fileset Dir= "${build.testcase.dir}" > <include name= "**/*test.class"/></fileset> </batchtest></ junit> <junitreport todir= "${report folder}" > <fileset dir= "${report folder}" > <include name= "TEST-* . xml "/> </fileset> <report format=" frames "todir=" ${report folder} "/> </junitreport> </target ><target name= "clean" description= "deletes compiled and generated code" > <delete dir= "${report folder}"/ > </target> </project>


    • Output the test results to ${report folder}, where ${report folder} is the report directory, note that Ref-lib does not forget to introduce JUnit's jar package
    • Executing junit.xml in the build

    • Then increase the post-build operation publish JUnit test result report

    • After saving and building, you can see the test results and the trend chart

Continuous Integration 4---Unit test solution

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.