vendredi 16 octobre 2015

Mockito - Verify recursive methods

I have a method, which is recursive:

For example:

   public static int myMethod(int index, int number) {
        if (index<4){
            index = index + number;
            return myMethod(index, number+1);
        }
        return index;
    }

Now this is just a basic example. When I now want to test, how can I verify with Mockito, how many times the method gets called, because the parameters change?

verify(myMethod(1,2)).times(3) would not work, because it only gets called once, then 1,2 will change.

Aucun commentaire:

Enregistrer un commentaire