【问题标题】:Spock test: Eclipse doesn't seem to recoganize the data variables in Where clauseSpock 测试:Eclipse 似乎无法识别 Where 子句中的数据变量
【发布时间】:2019-02-08 17:58:17
【问题描述】:

我有一个使用 where 子句的 Spock 测试。在 Eclipse 中,测试文件是使用 Groovy 编辑器打开的,但是代码(“testName”)和where 子句(testNum 和 testName)中的数据变量都带有下划线。 Maven 构建工作正常。

谁能告诉我如何在 Eclipse 中解决这个问题?

  @Unroll
  def 'Test #testNum'() {
      def tname = testName

      ......

      where:
         testNum  |  testName
          '1'     | 'test #1'
  }

【问题讨论】:

  • 你不能... IntelliJ 能识别它们,但 Eclipse 不能
  • @tim_yates 谢谢。我希望 Eclipse 有一个插件。

标签: eclipse groovy spock


【解决方案1】:

我已经有一段时间没有使用 Eclipse,但定义测试参数可能会让 Eclipse 更容易混淆:

@Unroll
def 'Test #testNum'(String testNum, String testName) {

    def tname = testName

    ......

    where:
    testNum  |  testName
    '1'      | 'test #1'
}

【讨论】:

【解决方案2】:

我可以通过运行 Spock 转换来消除下划线,将其添加到 eclipse.ini 的末尾:

-Dgreclipse.globalTransformsInReconcile=org.spockframework.compiler.SpockTransform

但是,推断的 testName 类型是 Object(请参阅我在另一个答案下的评论)。

【讨论】:

    猜你喜欢
    • 2017-04-27
    • 1970-01-01
    • 2016-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-08
    • 1970-01-01
    相关资源
    最近更新 更多