- 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