2015-04-06 103 views
1

我正在尝试使用spock运行geb测试。我在Groovy脚本,这是摆在/src/main/groovy书面一切,看起来像下面使用gradle运行spock/geb测试时出现MissingMethodException错误

import spock.lang.Specification 
import geb.Browser 
import org.openqa.selenium.firefox.FirefoxDriver 

class AccessCookieInFF{ 
... 
} 

class BrowserSpec extends Specification { 

    def CookieTest(){ 
      given: ... 
      when: ... 
     then: ... 
        } 
} 

def newTest= new BrowserSpec() 
newTest.CookieTest() 

运行上面的设置给了我

Exception in thread "main" groovy.lang.MissingMethodException: No signature of m 
ethod: BrowserSpec.CookieTest() is applicable for argument types:() values: [] 

简单Groovy脚本运行良好与我的gradle这个设置。有人可以请指出,这里有什么错。谢谢!

+0

你为什么试图以一种如此奇怪的方式运行测试?第一种方法的 – Opal

+0

应该从lowerCase开始。看到Java约定,第二次所有的测试应该从测试开始.. – Koloritnij

+0

@Koloritnij我改变了案例,但我仍然得到相同的确切错误。请你解释一下你的意思应该从'test'开始。我对geb/spock – user1207289

回答

0

通过在/src/test/groovy中放置groovy测试文件并根据以下链接对build.gradle文件进行一些更改并通过命令gradle test来运行它,从而实现了这项工作。测试文件现在看起来像下面(我删除class AccessCookieInFF其他原因)

import spock.lang.Specification 
import geb.Browser 
import org.openqa.selenium.firefox.FirefoxDriver 

    class BrowserSpec extends Specification { 
    def cookieTest(){ 
        given: ... 
        when: ... 
        then: ... 

        } 
    } 

This是非常有益的。谢谢

相关问题