????????+??????????
???????????? ???????[ 2015/4/21 13:22:00 ] ??????????????? ????????
??????????????
????1.?????????Unitils
??????????Untils??????????????????????
????Unitils??????????????????????http://www.unitils.org/summary.html?????????????У?
????·DatabaseModule:???????????????????
????·DbUnitModule:???DBunit???в??????????
????·HibernateModule:Hibernate??????????????????mapping???
????·MockModule:??????Unitils??mock??????mock????
????·EasyMockModule:??????EasyMock??mock??????mock????
????·InjectModule:??????mock??????????????
????·SpringModule:???????Spring??????????????????Spring Beans
????????????????????????????????????????????????????????У?
????·?Spring???????????????????????
????·???????????????????????????
????·???????Assert????
????2.??????????Unitils
?????????.???UnitilsJUnit4
??????????.????????????annotation??@RunWith(UnitilsJUnit4TestClassRunner.class)
??????????.????UnitilsJUnit3(UnitilsJUnit4)????????????MyUnitilsJunit3??????????????????????????????MyUnitilsJunit3?????????????Junit3 TestCase?????????磺AbstractDependencyInjectionSpringContextTests???????????????????????????????
????3.???Unitils????Spring???????????
??????????????ù????Spring????
????@SpringApplicationContext({"/bean/profile/base-beans.xml"})
????public class DAOTestBase extends UnitilsJUnit4{
????}
????????????????Spring????
????public class UserDAOTest extends DAOTestBase{
????@SpringApplicationContext({"/bean/profile/base-beans.xml"??"/bean/profile/extra-beans.xml"})
????protected ApplicationContext applicationContext;
????@SpringBean("userDAO")
????private UserDAO userDAO;
????@SpringBeanByName
????private UserDAO userDAO;
????@SpringBeanByType
????private UserDAO userDAO;
????}
????4.???DBunit????????????????
????(1).??unitils.properties???н???????
????database.driverClassName=com.mysql.jdbc.Driver
????database.url=jdbc:mysql://192.168.205.62:3310/pro_general?characterEncoding=UTF-8
????database.userName=profile
????database.password=profile
????database.schemaNames=pro_general
????database.dialect=mysql
????????????????????????????????????????????CleanInsertLoadStrategy??InsertLoadStrategy??RefreshLoadStrategy??UpdateLoadStrategy????????壬??Щ??????????
????DbUnitModule.DataSet.loadStrategy.default=org.unitils.dbunit.datasetloadstrategy.impl.DeleteInsertLoadStrategy
???????????????????????????xml??excel????????????excel??xls?????????xlsx???????excel???????????????????????????????????????
????DbUnitModule.DataSet.factory.default=org.unitils.dbunit.datasetfactory.impl.XlsDataSetFactory
????(2).???????????????????
????@DataSet
????public class TagTest extends DAOTestBase{
????@ExpectedDataSet
????public void testUpdate(){
????}
????}
????Annotation@DataSet????????μ????в????????????????????????????DataSet?п??????????????????·?????????????????????????????в???????????${ClassName.methodName}???????????????${ClassName}????????????????????????ù???????????????
????@ExpectedDataSet????????н???????????????????????????????????????????????????????????????????“-result”??
????5.???Unitils???????????????????????
????@Transactional(TransactionMode.ROLLBACK)
???????????????????Transactional Anotation???????????????з?????????????Unitils?????bug?????Transactional Anotation????????????UnitilsJUnit4????@RunWith???????С?
?????????????
???????????????Clover?????в?????????????????????????????????????Clover??????????????????licence??????????????????????????????cobertura?????Jcoverage?????????maven??????
??????maven??pom?????????
????<build>
????<plugins>
????……
????<plugin>
????<groupId>org.codehaus.mojo</groupId>
????<artifactId>cobertura-maven-plugin</artifactId>
????<version>2.4-SNAPSHOT</version>
????<configuration>
????<formats>
????<format>html</format>
????<format>xml</format>
????</formats>
????<instrumentation>
????<!--<ignore>.*</ignore>-->
????<excludes>
????<exclude>**/*Test.class</exclude>
????<exclude>**/Abstract*TestCase.class</exclude>
????<exclude>**/*Constants.class</exclude>
????<exclude>**/*interface/*.class</exclude>
????<exclude>**/*domain/*.class</exclude>
????<exclude>**/*dataobject/*.class</exclude>
????<exclude>**/web/**/*.class</exclude>
????</excludes>
????</instrumentation>
????</configuration>
????</plugin>
????......
????</plugins>
????</build>
???????mvn cobertura:cobertura??????ó?????????????????????????Line coverage??branch coverage???ó??????????????????λ???????cobertura??maven????в?δ??merge???????????????cobertura-maven-plugin????ó???????????????????
?????????????????????λ?????????????????????????£?
????1.????coberturahttp://cobertura.sourceforge.net/download.html.(??????????????????????????bin?????????src.??????????????????????src??cobertura?????ant??????)
????2.???mvn cobertura:cobertura??????????????????????target/cobertura?????????cobertura.ser???????????pom?????target/cobertura???2????cobertura.ser
????3.?????????cobertura.ser????merge???????????????cobertura.ser?????
????../cobertura-1.9.3/cobertura-merge.sh--datafile./target/cobertura/cobertura.ser./profile-ao/target/cobertura/cobertura.ser./profile-core/target/cobertura/cobertura.ser./profile-dal/target/cobertura/cobertura.ser./profile-client/target/cobertura/cobertura.ser./profile-common/target/cobertura/cobertura.ser
??????????????????????pom?????target/cobertura?????????????????????cobertura.ser???
????4.?????mvn cobertura:cobertura??????????????????????????????????
????????????+?????????
???????????????????????????????????????????????????????????????????????????????????????????????????CruiseControl
????1???????????????????????????????????
??????1????maven?ж?cobertura??check???????????
????<plugin>
????<groupId>org.codehaus.mojo</groupId>
????<artifactId>cobertura-maven-plugin</artifactId>
????<configuration>
????<check>
????<branchRate>85</branchRate>
????<lineRate>85</lineRate>
????<haltOnFailure>true</haltOnFailure>
????<totalBranchRate>85</totalBranchRate>
????<totalLineRate>85</totalLineRate>
????<packageLineRate>85</packageLineRate>
????<packageBranchRate>85</packageBranchRate>
????<regexes>
????<regex>
????<pattern>com.taobao.memberprofile.core.*</pattern>
????<branchRate>90</branchRate>
????<lineRate>80</lineRate>
????</regex>
????<regex>
????<pattern>com.taobao.memberprofile.dal.*</pattern>
????<branchRate>40</branchRate>
????<lineRate>30</lineRate>
????</regex>
????</regexes>
????</check>
????</configuration>
????<executions>
????<execution>
????<goals>
????<goal>check</goal>
????</goals>
????</execution>
????</executions>
????</plugin>
??????2??????????????????cobertura??check????
???????CruiseControl??????config.xml
????<schedule Interval="60">
????<maven2 MvnHome="/opt/taobao/install/apache-maven-2.1.0"PomFile="${checkoutdir}/${project.name}/pom.xml"
????Goal="install cobertura:check cobertura:cobertura"/>
????</schedule>
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11