2013-03-22 46 views
0

試圖找出這個geb和spock測試框架並遇到一些問題。現在我只是試圖讓spock工作。Groovy獲取字符串錯誤

@Grab(group='org.codehaus.geb', module='geb-core', version='0.7.2') 
@Grab(group='org.seleniumhq.selenium', module='selenium-firefox-driver', version='2.31.0') 
@Grab(group='org.spockframework', module='spock-core', version='0.6-groovy-1.7') 
@Grab(group='org.codehaus.groovy', module='groovy-all', version='1.8.6') 

import geb.* 
import org.openqa.selenium.firefox.FirefoxDriver 
import spock.lang.* 


class TestSimpleGoogle extends Specification { 
    def "pushing an element on the stack"() { 
     when: "A variable is defined" 
     title = "Hello" 

     then: "Check to see if it equals hello" 
     assert(title == "Hello") 
    } 
} 

這裏是我的輸出從命令終端

Caught: java.lang.NoSuchMethodError: org.codehaus.groovy.runtime.InvokerHelper.getVersion()Ljava/lang/String; 
java.lang.NoSuchMethodError: org.codehaus.groovy.runtime.InvokerHelper.getVersion()Ljava/lang/String; 
     at org.spockframework.util.GroovyReleaseInfo.getVersion(GroovyReleaseInfo.java:23) 
     at org.spockframework.util.VersionChecker.<clinit>(VersionChecker.java:18) 
     at org.spockframework.compiler.SpockTransform.<init>(SpockTransform.java:43) 

思想得到什麼?

+0

爲什麼你使用Spock for groovy 1.7? – 2013-03-22 14:28:36

回答

1

你抓住斯波克的錯版爲你抓住了Groovy的版本,我不知道爲什麼你抓住的Groovy在所有...

這個工程的Groovy 2.1下。 2:

@Grab('org.spockframework:spock-core:0.7-groovy-2.0') 
import spock.lang.* 

class TestSimpleGoogle extends Specification { 
    def "pushing an element on the stack"() { 
    when: "A variable is defined" 
     def title = "Hello" 

    then: "Check to see if it equals hello" 
     title == "Hello" 
    } 
} 
1

對於Groovy 1.8,您需要一個以groovy-1.8結尾的Spock版本。要開始,唯一需要的就是@Grab(group='org.spockframework', module='spock-core', version='0.7-groovy-1.8')