我刚刚将 spock 添加到 Grails 2.2.3 项目中
我向Buildonfig.groovy添加了以下依赖项:
plugins { test(":spock:0.7") }
然后创建了我的规范类,“test/unit/LocationSpec.groovy:
import grails.test.mixin.* import org.junit.* import spock.lang.* /** * See the API for {@link grails.test.mixin.support.GrailsUnitTestMixin} for usage instructions */ @TestFor(Location) class LocationSpec extends Specification { def setup() { } def cleanup() { } def "compare"() { when: def loc1 = new Location(description:descr1) def loc2 = new Location(description:descr2) then: loc1.compareTo(loc2) == descr1.compareTo(descr2) where: descr1 | descr2 | pidm1 | pidm2 "foo" | "foo" | 1333868 | 1333868 } }
但是,规范导入行出现以下错误:
Groovy:unable to resolve class spock.lang.Specification