黄瓜JVM';s(Groovy)“;世界(钩子)“;对象混合和Intellij导航

黄瓜JVM';s(Groovy)“;世界(钩子)“;对象混合和Intellij导航,groovy,intellij-idea,cucumber-jvm,Groovy,Intellij Idea,Cucumber Jvm,我正在intellij中使用cucumber JVM(Groovy)开发cucumber场景。我必须说,在eclipse中这样做比在eclipse中做要好得多 我想解决一个小问题,让我的团队变得更好。但由于我是Intellij的新手,我需要以下方面的帮助: 当我在step def文件(groovy)中时,Intellij似乎看不到Cumber“World”对象中定义的变量和方法。因此,对于那些有点烦人的东西,不要获得IDE支持(自动完成等)。我怎样才能解决这个问题 IntelliJ IDEA期

我正在intellij中使用cucumber JVM(Groovy)开发cucumber场景。我必须说,在eclipse中这样做比在eclipse中做要好得多

我想解决一个小问题,让我的团队变得更好。但由于我是Intellij的新手,我需要以下方面的帮助:

  • 当我在step def文件(groovy)中时,Intellij似乎看不到Cumber“World”对象中定义的变量和方法。因此,对于那些有点烦人的东西,不要获得IDE支持(自动完成等)。我怎样才能解决这个问题

IntelliJ IDEA期望一个对象内部世界关闭。因此,您可以在每个步骤定义文件中定义以下块:

World {
    new MockedTestWorld()
}
MockedTestWorld.groovy:

要清除重复的世界定义,我们使用最后一个粘合初始值设定项和一点复制粘贴:

real/InitSteps.groovy

遗留/InitSteps.groovy

最后,运行配置如下(使用不同的胶水):

class MockedTestWorld implements TestWorld {
    @Lazy
    @Delegate
    @SuppressWarnings("GroovyAssignabilityCheck")
    private TestWorld delegate = {
        throw new UnsupportedOperationException("" +
            "Test world mock is used ONLY for syntax highlighting in IDE" +
            " and must be overridden by concrete 'InitSteps.groovy' implementation.")
    }()
}
def world
GroovyBackend.instance.@worldClosures.clear()
GroovyBackend.instance.registerWorld {
    return world ?: (world = new RealTestWorld1()) // Actual initialization is much longer
}
def world
GroovyBackend.instance.@worldClosures.clear()
GroovyBackend.instance.registerWorld {
    return world ?: (world = new LegacyTestWorld1())
}
// Real setup
glue = { "classpath:test/steps", "classpath:test/real", },

// Legacy setup
glue = { "classpath:test/steps", "classpath:test/legacy", },