在Intellij Idea中调试时,在评估表达对话框中无法访问SPOCK测试的变量

发布于 2025-01-29 14:47:52 字数 539 浏览 3 评论 0原文

在以下SPOCK测试中:

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

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

在预期块上设置代码行中的断点时,无法访问变量的值(a,b)在调试时。返回的异常是:

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

围绕它的唯一方法是手动从中复制数据,其中零件中的一部分纳入评估表达式对话框中。

我如何使用评估表达式而无需手动从中复制一个测试的一部分的值?

我使用的是Intellij Idus Ultimate 2022.1在MacOS 12 Monterey上运行的Groovy版本4,而Gradle作为构建工具。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一枫情书 2025-02-05 14:47:52

当我明确声明参数时,它对我有用。

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
}

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
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文