I am new to mockito. I am trying to test a function which has a functionality that it registers a username. So before updating the new username, it checks if that username is already registered(present in DB) or not. So here I have to test two cases: 1. Success: The username registration successful.(No username with given name in DB found)
- Failure: Failed to register as the username is already registered.
I am not able to understand how to mock the functions. The functions signature is as follows:
func registerName(User){
cond = checkUsername(User);
if(cond) return false; //since user is found
else CompleteRegistration(User);}
Can someone help me to mock the function. Also the checkUsername() and CompleteRegistration() only have basic DB interactions.
Aucun commentaire:
Enregistrer un commentaire