How to use Spock 0.6
This article mainly explains how to use Spock 0.6. the content of the explanation in the article is simple and clear, and it is easy to learn and understand. please follow the editor's train of thought to study and learn how to use Spock 0.6. let's go deep together.
Spock 0.6 has been released, and Spock 0.6 has added support for Groovy 1.8, Groovy 2.0, and and Grails 2.0. For a detailed record of improvements, please see here.
Spock is a testing framework for Java and Groovy applications. Sample code:
Import groovy.sql.Sql import spock.lang.* class DatabaseDriven extends Specification {@ Shared sql = Sql.newInstance ("jdbc:h3:mem:", "org.h3.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, an 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]