I'm just trying to check if an user is created with an async method , I'm new to testing and I'm using ArgumentCaptor to check if the onRegistrationSucces() callback is called 1 time to check that it was succefull.
This is What I have done to test it
RegisterTest.kt
@Test fun should_SignUpUser(){ presenter.signUp("test1","[email protected]","asdasd") verify(interactor).createUserWithEmailAndPassword("test1","[email protected]","asdasd",object: RegisterInteractor.RegisterCallBack{ override fun onRegistrationSucces() { callbackCaptor.capture() } override fun onRegistrationFailure(errorMsg: String) { callbackCaptor.capture() } }) verify(callbackCaptor.value.onRegistrationSucces(), times(1)) } And this is the presenter method that I'm trying to test
RegisterPresenter.kt
override fun signUp(fullName:String, email: String, password: String) { view?.showProgress() registerInteractor.createUserWithEmailAndPassword(fullName,email, password, object : RegisterInteractor.RegisterCallBack { override fun onRegistrationSucces() { if(isViewAttached()){ view?.navigateToLogin() view?.hideProgress() } } override fun onRegistrationFailure(errorMsg:String) { if(isViewAttached()){ view?.showError(errorMsg) view?.hideProgress() } } }) } But I'm getting this error
Argument(s) are different! Wanted: interactor.createUserWithEmailAndPassword( "test1", "[email protected]", "asdasd", com.testapp.presentation.register.presenter.RegisterPresenterTest$should_SignUpUser$1@c86b9e3 ); -> at com.testapp.presentation.register.presenter.RegisterPresenterTest.should_SignUpUser(RegisterPresenterTest.kt:119) Actual invocation has different arguments: interactor.createUserWithEmailAndPassword( "test1", "[email protected]", "asdasd", com.testapp.presentation.register.presenter.RegisterPresenter$signUp$1@10aa41f2 ); -> at com.testapp.presentation.register.presenter.RegisterPresenter.signUp(RegisterPresenter.kt:64)