The road to the architect 25th day SSH Unit test and Dbunit integration (on)

Source: Internet
Author: User
Tags ssh

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>

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.