Spock测试:Eclipse似乎没有识别Where子句中的数据变量


12345
2024-12-30 02:10:44 (2月前)
  1. 我有一个使用where子句的Spock测试。在Eclipse中,测试文件是使用Groovy Editor打开的,但是代码(“testName”)和where子句(testNumtestName)中的数据变量......

3 条回复
  1. 0# 雪浴冰灵 | 2019-08-31 10-32



    我没有使用Eclipse很长一段时间,但是定义测试参数可能会让Eclipse更加困惑:




    1. @Unroll
      def Test #testNum’(String testNum, String testName) {

    2. def tname = testName
    3. ......
    4. where:
    5. testNum  |  testName
    6. '1'      | 'test #1'
    7. }

    8. </code>

  2. 1# 烏鴉喝酒 | 2019-08-31 10-32



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




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

    2. </code>


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







登录 后才能参与评论