Spock0.6发布Java测试框架

Spock 0.6 发布,Spock 0.6 增加对 Groovy 1.8, Groovy 2.0, and Grails 2.0 的支持,详细的改进记录请看这里。

Spock 是适合 Java 和 Groovy 应用程序的一个测试框架。示例代码:

 
 
 
  1. import groovy.sql.Sql  
  2.  
  3. import spock.lang.*  
  4.  
  5. class DatabaseDriven extends Specification {  
  6.   @Shared sql = Sql.newInstance("jdbc:h2:mem:", "org.h2.Driver")  
  7.    
  8.   // normally an external database would be used,  
  9.   // and the test data wouldn't have to be inserted here  
  10.   def setupSpec() {  
  11.     sql.execute("create table maxdata (id int primary key, a int, b int, c int)")  
  12.     sql.execute("insert into maxdata values (1, 3, 7, 7), (2, 5, 4, 5), (3, 9, 9, 9)")  
  13.   }  
  14.  
  15.   def "maximum of two numbers"() {  
  16.     expect:  
  17.     Math.max(a, b) == c  
  18.  
  19.     where:  
  20.     [a, b, c] << sql.rows("select a, b, c from maxdata")  
  21.   }  

下载地址:http://code.google.com/p/spock/downloads/list

本文题目:Spock0.6发布Java测试框架
网页URL:http://www.shufengxianlan.com/qtweb/news14/372064.html

网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联