2

我使用 MockK 进行单元测试。我如何使用可为空和不可为空的参数来模拟私人通话?

我的方法:

private fun trySaveLogin(session: Session, login: String, passwordHash: String?, passwordHashNoSalt: String?, userInfo: UserInfo) { // doWork}

已经尝试过:

every { loginPresenter["trySaveLogin"](allAny<Any>())  } just Runs
every { loginPresenter["trySaveLogin"](any<String>(), any<String>(), any<String>(), any<String>(), any<UserInfo>()) } just Runs

一切都返回错误:

io.mockk.MockKException: can't find function trySaveLogin(-4d6de1423b10ebb8, ...) for dynamic call
4

1 回答 1

2

用这个:

every { loginPresenter["trySaveLogin"](any<Session>(), any<String>(), any<String>(), any<String>(), any<UserInfo>())  as Unit } just Runs
于 2019-09-30T09:52:45.583 回答