Home > OS >  Variables of Spock test are not accessible in Evaluate Expression dialog while debugging in IntelliJ
Variables of Spock test are not accessible in Evaluate Expression dialog while debugging in IntelliJ

Time:05-18

In the following Spock test:

def 'simple assertion'() {
    expect:
    Math.max(a, b) == max

    where:
    a | b | max
    3 | 5 | 5
    4 | 9 | 9
    }

When setting a breakpoint in the code line at the expect block, it is not possible to access the value of the variables (a, b) from the Evaluate Expression... dialog while debugging. The returned exception is:

groovy.lang.MissingPropertyException: No such property: a, b for class: DUMMY

The only way around it is by manually copying the data from the where part into the evaluate expression dialog.

How can I use evaluate expression WITHOUT having to manually copy the values from the where part of the test?

I am using IntelliJ IDEA Ultimate 2022.1 running on macOS 12 Monterey with Groovy version 4 and Gradle as a build tool.

CodePudding user response:

It worked for me when I declared the parameters explicitly.

def 'simple assertion'(int a, int b, int max) {
    expect:
    Math.max(a, b) == max

    where:
    a | b | max
    3 | 5 | 5
    4 | 9 | 9
}
  • Related