我有一个 Kotlin 类(问题被简化为有一个基本示例),其中有一个testedMethod()
我想测试交互的方法。
我想确保传递给正确的参数anotherMethod()
,我的问题是参数不是一个值,而是一个lambda 函数。
我正在寻找 Kotlin 中的一个简单解决方案,它可能基于也可能不基于java 的这个解决方案。
class TestedClass {
fun testedMethod() {
anotherMethod({ passedMethod() })
}
fun passedMethod() {}
fun anotherMethod(lambdaParameter: () -> Unit) {
// Does something with lambdaParameter
}
}