lundi 23 mars 2020

Ignore method call when mockito testing

I have state capturing test which needs to test something like this:

init{
  loadValues();
}

fun loadValues(){
  setStateToLoadingHere();

  try{
    val result: List<Anything> = getValues();
    setStateToSuccessHere(result);
  }catch(Exception e){
    setStateToErrorHere();
  }
}

I want to ignore this getValues() method call to be able to test the loading state only. Is there a way where I can ignore this whole try catch? If I don't do that I'll get NPE inside my test.

Aucun commentaire:

Enregistrer un commentaire