First, the preface
In 23 days we introduced a dependency library file that uses MAVEN to download the project, using ant to build the war package. Today we will use junit+dbunit on this basis to conduct a framework with a unit test report.
Goal:
Automate unit tests and generate unit test reports before each package is packaged
Generate a packaged file that is to be sent to the war package
The unit test code is not able to be hit in a formal war package to be launched, unit tests are used only
Test the DAO layer with mock data so that the test results of the DAO method can be expected
Second, the unit test report generated by junit+ant
This is a junit-generated test report that can be run with an ant task and automatically generate such an HTML test report, and to generate such a junit test we need to invoke the <junitreport> in the ant task This task, the sample code is as follows:
<target name= "Junitreport" > <junit printsummary= "on" haltonfailure= "false" failureproperty= "tests.failed" Showoutput= "true" > <classpath> <pathelement path= "${dist.dir}/${webappqaname}/web-inf/classes"/> & Lt;fileset dir= "${lib.dir}" > <include name= "*.jar"/> </fileset> <fileset dir= "${ext-lib.dir}" > <include name= "*.jar"/> </fileset> </classpath> <formatter type= "xml"/> <ba Tchtest todir= "${report.dir}" > <fileset dir= "${dist.dir}/${webappqaname}/web-inf/classes" > <include nam E= "Org/sky/ssh/ut/test*.*"/> </fileset> </batchtest> </junit> <junitreport todir= "${report . Dir} "> <fileset dir=" ${report.dir} "> <include name=" test-*.xml "/> </fileset> <report fo Rmat= "Frames" todir= "the"/> </junitreport> <fail if= "tests.failed" >-----------------------------
----------------------------One or more tests failed, check the "for detail ...---------------------------------------------------------< /fail> </target>