Grails 2.2.3在Classpath中找不到Spock [英] Grails 2.2.3 Can't Find Spock on Classpath

查看:104
本文介绍了Grails 2.2.3在Classpath中找不到Spock的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚将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

  1. I added the following dependency to Buildonfig.groovy:

    plugins {
        test(":spock:0.7")
    }
    

  2. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆