我正在尝试在单元测试中验证参数中的kotlin功能,但是失败了。这是我的代码
单元测试:
verify(moveToNextStepUseCase).execute(validateStepAssemblyUseCase.validate(ID),
{ view.showCompleteAssemblyConfirmDialog(type) },
{ view.showCompleteAssemblyErrorDialog() })
我的moveToNextStepUseCase
代码:
interface MoveToNextStepUseCase {
fun execute(validator: () -> Observable<Boolean>, successAction: () -> Unit, errorAction: () -> Unit)
}
我的呼叫代码:
moveToNextStepUseCase.execute(
validateStepAssemblyUseCase.validateMissingAssembly(assignmentId),
{ view.showCompleteAssemblyConfirmDialog(currentStepId) },
{ view.showCompleteAssemblyErrorDialog() }
)
但是运行测试后出现错误:
Argument(s) are different! Wanted:
moveToNextStepUseCase.execute(
Function0<io.reactivex.Observable<java.lang.Boolean>>,
(move next assembly step incomplete case$1) Function0<kotlin.Unit>,
(move next assembly step incomplete case$2) Function0<kotlin.Unit>
);
Actual invocation has different arguments:
moveToNextStepUseCase.execute(
Function0<io.reactivex.Observable<java.lang.Boolean>>,
() Function0<kotlin.Unit>,
() Function0<kotlin.Unit>
);
谁知道为什么在实际调用中该参数为空? ()