Geb 文档表示 IDEA 通过 Groovy 插件 ( http://www.gebish.org/manual/current/ide-and-typing.html#intellij_idea_support ) 支持 Geb。特别是,它说“ IntelliJ IDEA(自版本 12 起)特别支持编写 Geb 代码。这是内置于 Groovy 支持中的;不需要额外的安装。”但是,我在 IDEA 13.x 或 14 中没有看到这一点。一切正常并运行,但我没有得到任何代码完成或在我的页面中定义的任何内容 DSL 定义的提示。此外,我的内容DSL 引用显示带有“下划线”格式,用于指示未知/动态/仅限运行时的 Groovy 元素。由于 Geb 文档明确表示它应该提供此功能,所以我试图弄清楚我是否遗漏了某些内容?
最佳答案
您只能在页面定义/类内或当 IntelliJ 知道页面类型时获得内容定义提示。如果您不跟踪页面类型,将不会有内容定义提示,因为 IntelliJ 无法确定当前页面类型是什么,并且无法提供自动完成功能。
class MyPage extends Page {
static content {
links { $("a") }
fistLink { links.first() } //Intellij will understand what links are here
}
int getLinksCount() {
links.size() // IntelliJ will understand what links are here
}
}
class MySpec extends GebSpec {
...
to(MyPage)
myPage.links // Intellij will not understand/autocomplete links here
...
def myPage = to(MyPage)
myPage.links // Intellij will understand/autocomplete links here
...
}
此外,据我所知,这仅适用于终极版,而不适用于社区版。
关于intellij-idea - Intellij-IDEA 中的 Geb 创作支持吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30220591/