I have a Spock class, that when run as a test suite, throws Unable to resolve iconRow as content for geb.Page, or as a property on its Navigator context. Is iconRow a class you forgot to import?
unless I annotate my class with @Stepwise. However, I really don't want the test execution to stop on the first failure, which @Stepwise does.
I've tried writing (copy and pasting) my own extension using this post, but I still get these errors. It is using my extension, as I added some logging statements that were printed out to the console.
Here is one of my modules:
class IconRow extends Module {
static content = {
iconRow (required: false) {$("div.report-toolbar")}
}
}
And a page that uses it:
class Report extends SomeOtherPage {
static at = {$("div.grid-container").displayed}
static content = {
iconRow { module IconRow }
}
}
And a snippet of the test that is failing:
class MyFailingTest extends GebReportingSpec {
def setupSpec() {
via Dashboard
SomeClass.login("SourMonk", "myPassword")
assert page instanceof Dashboard
nav.goToReport("Some report name")
assert page instanceof Report
}
@Unroll
def "I work"() {
given:
at Report
expect:
this == that
where:
this << ["some list", "of values"]
that << anotherModule.someContent*.@id
}
@Unroll
def "I don't work"() {
given:
at Report
expect:
this == that
where:
this << ["some other", "list", "of values"]
that << iconRow.columnHeaders*.attr("innerText")*.toUpperCase()
}
}
When executed as a suite I work
passes and I don't work
fails because it cannot identify "iconRow" as content for the page. If I switch the order of the test cases, I don't work
will pass and I work
will fail. Alternatively, if I execute each test separately, they both pass.
What I have tried:
- Adding/removing the
required: true
property from content in the modules - Prefixing the module name with the class, such as
IconRow.iconRow
- Defining my modules as static
@Shared
properties - Initialize the modules both in and outside of my
setupSpec()
- Making simple getter methods in each module's class that return the module, and referencing content such as
IconRow.getIconRow().columnHeaders*.attr("innerText")*.toUpperCase()
- Moving the contents of my
setupSpec()
intosetup()
- Adding
autoClearCookies = false
into my GebConfig.groovy - Making a
@Shared Report report
variable and prefix all modules with that such asreport.iconRow
Very peculiar note about that last bullet point -- it magically resolves the modules that don't have the prefix -- so it won't resolve report.IconRow
but will resolve just iconRow
-- absolutely bizarre, because if I remove that variable the module that was just previously working suddenly can't be resolved again. I even tried declaring this variable and then not prefixing anything, and that did not work either.
Another problem that I keep banging my head against the wall with is that I'm also not sure of where the problem is. The error it throws leads me to believe that it's a project setup issue, but running each feature individually works fine, so it appears to be resolving the classes just fine.
On the other hand, perhaps it's an issue with the session and/or cookies? Although I have yet to see any official documentation on this, it seems to be the general consensus (from other posts and articles I've read) that only using @Stepwise
will maintain your session between feature methods. If this is the case, why is my extension not working? It's pretty much a copy and paste of @Stepwise
without the skipFeaturesAfterFirstFailingFeature
method (I can post if needed), unless there is some other stuff going on behind the scenes with @Stepwise
.
Apologies for the wall of text, but I've been trying to figure this out for about 6 hours now, so my brain is pretty fried.
Aucun commentaire:
Enregistrer un commentaire