Grails 2.2.3在Classpath中找不到Spock [英] Grails 2.2.3 Can't Find Spock on Classpath
问题描述
我刚刚将spock添加到了Grails 2.2.3项目中。我添加了以下依赖项到 Buildonfig。 groovy :
插件{
test(:spock:0.7)
}
然后创建了我的规范类,test / unit / LocationSpec.groovy :
输入grails.test.mixin。*
输入org.junit。*
import spock.lang。*
/ **
*查看使用说明{@link grails.test.mixin.support.GrailsUnitTestMixin}的API
* /
@TestFor(Location)
class LocationSpec extends Specification {
def setup(){
}
def cleanup(){
}
defcompare(){
when:
def loc1 = new Location(描述:descr1)
def loc2 = new Location(description:descr2)
then:
loc1.compareTo(loc2)== descr1.compareTo(descr2)
其中:
descr1 | descr2 | pidm1 | pidm2
foo| foo| 1333868 | 1333868
}
}
然而,我收到了以下错误与规格导入行:
Groovy:无法解决类spock.lang.Specification
Derp! RTFM
从 http:/ /grails.org/plugin/spock :
$ b
Grails 2.2使用Groovy 2.0,它需要一个特殊的Spock
版。因此,要在Grails 2.2中使用Spock插件,请修改
BuildConfig.groovy文件以包含以下内容:
grails.project.dependency.resolution = {
repositories {
grailsCentral()
mavenCentral()
}
依赖关系{
testorg.spockframework:spock-grails-support:0.7-groovy-2.0
plugins {
test(:spock:0.7){excludespock-grails-支持}
}
}
I just added spock to a Grails 2.2.3 project
I added the following dependency to Buildonfig.groovy:
plugins { test(":spock:0.7") }
Then created my Specification class, "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 } }
However I am getting the following errors with the Specification import line:
Groovy:unable to resolve class spock.lang.Specification
Derp! R.T.F.M.
From http://grails.org/plugin/spock:
Grails 2.2 uses Groovy 2.0, which requires a special Spock version. So to use the Spock plugin with Grails 2.2, modify you BuildConfig.groovy file to include the following:
grails.project.dependency.resolution = {
repositories {
grailsCentral()
mavenCentral()
}
dependencies {
test "org.spockframework:spock-grails-support:0.7-groovy-2.0"
}
plugins {
test(":spock:0.7") { exclude "spock-grails-support" }
}
}
这篇关于Grails 2.2.3在Classpath中找不到Spock的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!