jlp
jlp

Reputation: 1706

Spock test: Eclipse doesn't seem to recoganize the data variables in Where clause

I have a Spock test that uses where clause. In Eclipse the test file was opened with Groovy Editor, but the data variables both in the code ("testName") and in the where clause (testNum and testName) are underlined. The maven build works fine.

Can someone let me know how to fix this issue in Eclipse?

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

      ......

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

Upvotes: 0

Views: 70

Answers (2)

emilles
emilles

Reputation: 1179

I can get rid of the underlines by running the Spock transform add this to the end of eclipse.ini:

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

However, the inferred type of testName is Object (see my comment under the other answer).

Eclipse Groovy editor with Spock test

Upvotes: 0

Michael
Michael

Reputation: 2683

I did not use Eclipse for quite some time, but maybe defining test parameters could be less confusing for Eclipse:

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

    def tname = testName

    ......

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

Upvotes: 1

Related Questions