Java 测试框架,Spock 0.6 发布

openkk 13年前
     <div id="p_fullcontent" class="detail">     <p><a href="/misc/goto?guid=4958331801831245620" target="_blank">Spock </a>是适合 Java 和 Groovy 应用程序的一个测试框架。<br /> <br /> Spock 0.6 发布,Spock 0.6 增加对 Groovy 1.8, Groovy 2.0, and Grails 2.0 的支持,详细的改进记录请看<a href="/misc/goto?guid=4958331802633801334" target="_blank">这里</a>。<br /> <br /> 示例代码:</p>     <p></p>     <pre class="brush:java; toolbar: true; auto-links: false;">import groovy.sql.Sql    import spock.lang.*    class DatabaseDriven extends Specification {    @Shared sql = Sql.newInstance("jdbc:h2:mem:", "org.h2.Driver")       // normally an external database would be used,    // and the test data wouldn't have to be inserted here    def setupSpec() {      sql.execute("create table maxdata (id int primary key, a int, b int, c int)")      sql.execute("insert into maxdata values (1, 3, 7, 7), (2, 5, 4, 5), (3, 9, 9, 9)")    }      def "maximum of two numbers"() {      expect:      Math.max(a, b) == c        where:      [a, b, c] << sql.rows("select a, b, c from maxdata")    }  }</pre>     <p></p>    </div>