// Setup val mockedApiServices = mock<ApiServices>() val mockedLocalStorage = mock<LocalStorage>() val tested = UserRepository(InstantAppExecutors(), mockedApiServices, mockedLocalStorage) // given val token = "token" `when`(mockedApiServices.login(anyString(), anyString())) .thenReturn(just(ApiResponse.create(Response.success(token)))) // when tested.login("[email protected]", "bar") .observeForever(mock()) // then verify(mockedLocalStorage).setAccessToken(token) }