Geb 如何从另一个模块引用一个模块?

Geb how to reference a module from another module?

我试图从另一个模块中引用一个模块,但它没有按预期工作。我不确定哪里出了问题,所以我会让我的代码 example/stack trace 来说话。

主要测试规范:

class TestSpec extends GebReportingSpec {
//bunch of code yada yada
    def "someFeatureMethod"(){
        at Page1
        module1.doThing()
    }
}

这是第 1 页的样子:

class Page1 extends Page {
    static content = {
        module1 { module(new Module1())}
    }
}

这是模块 1 的样子:

class Module1 extends Module{
    static content = {
        module2 {module(new Module2())} //not going to type it out but assume module2 has a method named someFunction2()
    }

    def doThing(){
        //This is where I am unsure the most. I have tried a few different things in this section
        browser.at Page1
        module1.module2.someFunction2()
    }
}

我的堆栈跟踪是这样的:

groovy.lang.MissingPropertyException: Unable to resolve module1 as content for Page1 -> module1: Module1, or as a property on its Navigator context. Is module1 a class you forgot to import?

我确实导入了所有可能的东西。

如果可能的话,我想要的是能够在模块中包含一个模块,请解释它是如何实现的,谢谢。

doThing() 方法的正确语法如下:

def doThing(){
    module2.someFunction2()
}

当我早些时候尝试这个时,我实际上有一个 type-o,这就是我如此困惑的原因。修复我测试过的 type-o 后,此设置有效。