2017-05-18 2 views
2

Ich versuche, ein Modul aus einem anderen Modul zu referenzieren, und es funktioniert nicht wie erwartet. Ich bin mir nicht sicher, wo ich falsch gelaufen bin, also lasse ich mein Code-Beispiel/Stack-Trace sprechen.Geb wie ein Modul von einem anderen Modul zu referenzieren?

Haupttest-Spec:

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

Hier ist, was Seite1 wie folgt aussieht:

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

Hier ist, was Module1 wie folgt aussieht:

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() 
    } 
} 

Mein Stack-Trace so etwas wie dieses :

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? 

Ich habe alles importiert, was ich nur konnte.

Alles, was ich will, ist in der Lage, ein Modul in einem Modul zu haben, wenn dies möglich ist, bitte erläutern, wie es implementiert ist, danke.

Antwort

0

Die richtige Syntax in der doThing() Methode ist wie folgt:

def doThing(){ 
    module2.someFunction2() 
} 

ich ein Typ-o tatsächlich hatte, als ich dies früher versucht, weshalb ich so verwirrt war. Nach dem Reparieren der Typ-O habe ich getestet und diese Einrichtung funktioniert.

Verwandte Themen