单元测试
junit ,对应的测试模块,我们的开发人员已经 提交到cvs ,我们从cvs update 后,编译运行。在运行之前,先在数据库里 初始化 相应的测试数据,在ant 中,我们使用下面的方法 插入数据到 数据库:
<target name="dbinit_insert">
<sql
driver="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@192.168.100.1:1521:china"
userid="uni_app2"
password="ladodgers"
onfiltered="continue"
>
<transaction src="./sql/InsertTestOrderNoteData.sql"/> <!-- For Test Case TestUserLiveValidation -->
<transaction src="./sql/TestUserLiveValidationBegin.sql"/> <!-- For Test Case TestUserLiveValidation -->
<transaction src="./sql/InsertTestCreateInventoryData.sql"/> <!-- For Test Case TestCreateInventory -->
<transaction src="./sql/InsertTestPerformanceVenueData.sql"/> <!-- For Test Case TestPerformanceVenue -->
<transaction src="./sql/InsertTestPerformanceManifestData.sql"/> <!-- For Test Case TestPerformanceManifest -->
<transaction src="./sql/InsertTestPerformanceData.sql"/> <!-- For Test Case TestPerformance -->
<transaction src="./sql/InsertTestPerformancePriceCodeData.sql"/> <!-- For Test Case TestPerformancePriceCode -->
<classpath>
<path refid="lib.path"/>
</classpath>
</sql>
</target>
然后开始 运行单元测试。
在单元测试结束后,把插入的册书数据 清空,目的是 下次 运行 的时候,可以再次初始化 数据库。
<target name="dbinit_delete">
<sql
driver="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@192.168.100.1:1521:china"
userid="uni_app2"
password="ladodgers"
onfiltered="continue"
>
<transaction src="./sql/deleteTestOrderNoteData.sql"/> <!-- For Test Case TestUserLiveValidation -->
<transaction src="./sql/TestUserLiveValidationEnd.sql"/> <!-- For Test Case TestUserLiveValidation -->
<transaction src="./sql/deleteTestCreateInventoryData.sql"/> <!-- For Test Case TestCreateInventory -->
<transaction src="./sql/deleteTestPerformanceVenueData.sql"/> <!-- For Test Case TestPerformanceVenue -->
<transaction src="./sql/deleteTestPerformanceManifestData.sql"/> <!-- For Test Case TestPerformanceManifest -->
<transaction src="./sql/deleteTestPerformanceData.sql"/> <!-- For Test Case TestPerformance -->
<transaction src="./sql/deleteTestPerformancePriceCodeData.sql"/> <!-- For Test Case TestPerformancePriceCode -->
<classpath>
<path refid="lib.path"/>
</classpath>
</sql>
</target>
在我们的 build.xml 中,以下列顺序执行 target:
1。 cvs update code
2. call build.xml compile source code
3. call build.xml compile unit test source code
4. insert data to database .
5. run unit test
6. generate unit test report
7. run clover check unit test cover rate
8. generate unit test cover rate report
9. delete test data from data base
10. Email all report to PM and Leader . deploy these report base on web service .作者: wenl 时间: 2007-2-9 12:01
ding
LZ 强人
使劲ding作者: 论坛守护神 时间: 2007-2-9 16:12
拜读一下,楼主辛苦了。我们公司也是做java的,美国外包。。。。。作者: tracy-fmsi 时间: 2007-2-26 13:28
学习作者: hadywei 时间: 2007-3-16 09:45
作了一年的黑盒,想研究下白盒是怎么回事作者: dandan 时间: 2007-3-16 10:08
顶一下,呵呵,虽然还是看不太懂ORCAL代码........作者: star-drift0312 时间: 2007-6-27 18:05
ding作者: lawgend 时间: 2007-9-13 22:06
请问版主是使用什么工具进行单元测试覆盖度的计算的?