gpt4 book ai didi

testing - _(下划线)在 Spock 测试中意味着什么?

转载 作者:行者123 更新时间:2023-11-28 19:46:54 25 4
gpt4 key购买 nike

在一个 Spock 测试中,我在 then block 中看到一个奇怪的情况:

0 * someInstance._

这是什么意思?

最佳答案

_ 是通配符,任何对象。参见 here找到它的确切实现方式和here对于文档。 _ 例如,它用于检查参数无关紧要的方法的调用,然后它看起来像:

1 * obj.method(1, _)

在这种特殊情况下,它检查实例 obj 上的方法 method 是否以 1 作为第一个参数被调用一次,并且 任何事 都是一秒钟。

关于testing - _(下划线)在 Spock 测试中意味着什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27395638/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com