在以下 Spock 測驗中:
def 'simple assertion'() {
expect:
Math.max(a, b) == max
where:
a | b | max
3 | 5 | 5
4 | 9 | 9
}
在期望塊的代碼行中設定斷點時,(a, b)
除錯時無法從 Evaluate Expression... 對話框訪問變數的值。回傳的例外是:
groovy.lang.MissingPropertyException: No such property: a, b for class: DUMMY
解決這個問題的唯一方法是手動將部件中的資料復制where
到評估運算式對話框中。
如何使用評估運算式而不必手動復制where
測驗部分的值?
我正在使用在 macOS 12 Monterey 上運行的 IntelliJ IDEA Ultimate 2022.1 以及 Groovy 版本 4 和 Gradle 作為構建工具。
uj5u.com熱心網友回復:
當我明確宣告引數時,它對我有用。
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
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/479072.html