使用gradle运行spock / geb测试时出现MissingMethodException错误

时间:2015-04-06 19:49:37

标签: groovy gradle spock geb

我正在尝试使用spock运行geb测试。我在一个时髦的脚本中写了所有内容,这个脚本放在/src/main/groovy中,如下所示

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设置下运行正常。有人可以指出,这里有什么不对。谢谢!

1 个答案:

答案 0 :(得分:0)

通过将groovy测试文件放在/src/test/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非常有帮助。感谢