Sunday, 15 May 2011

spock - How to debug static code block in GEB Page model -



spock - How to debug static code block in GEB Page model -

i trying out geb , wanted debug static code block in examples. have tried set breakpoints seem unable inspect info used in static content block.

class googleresultspage extends page { static @ = { results } static content = { results(wait: true) { $("li.g") } result { -> results[i] } resultlink { -> result(i).find("a.l")[0] } firstresultlink { resultlink(0) } } }

any clue on how can debugged using illustration intellij?

since content block using dsl , undergoes transformation when compiled i'm thinking wouldn't possible debug without special back upwards ide, hope can prove me wrong.

the approach have been using define methods beyond core content. provides few benefits, including debugging support, ide autocompletion when writing tests, , refactoring support. drawback of course of study more verbose code, although tradeoff has been worth purposes.

here's how might googleresultspage:

class googleresultspage extends page { static @ = { results } static content = { results(wait: true) { $("li.g") } } navigator result(int i) { results[i] } navigator resultlink(int i) { result(i).find("a.l")[0] } navigator firstresultlink { resultlink(0) } }

then when writing test utilize more typed approach:

class myspec extends gebreportingspec { def "google search keyword should have first result"() { given: googlehomepage homepage = to(googlehomepage) when: homepage.search("keyword") then: googleresultspage resultspage = at(googleresultspage) resultspage.result(0).displayed } }

spock geb

No comments:

Post a Comment