Complete the code to create a mock of the UserRepository class using MockK.
val userRepository = [1]<UserRepository>()Use mockk to create a mock object in MockK.
Complete the code to stub the getUserName() method to return "Alice".
every { userRepository.[1]() } returns "Alice"The method to stub is getUserName as it returns the user name.
Fix the error in verifying that getUserName() was called exactly once.
verify(exactly = [1]) { userRepository.getUserName() }Use exactly = 1 to verify the method was called once.
Fill both blanks to create a spy of UserService and stub fetchData() to return "Data".
val userService = [1]<UserService>() every { userService.[2]() } returns "Data"
Use spyk to create a spy and stub the fetchData method.
Fill all three blanks to verify that saveUser() was called with any User object exactly twice.
verify(exactly = [1]) { userRepository.saveUser([2]) } val slot = slot<User>() verify { userRepository.saveUser(capture(slot)) } assert(slot.captured.name == [3])
Verify called twice, with any User object, and assert the captured user's name is "Alice".
