samedi 12 octobre 2019

Unit test loop has run for particular number of times

Lets say I have a method looking like this

static void forLoop(){
    for (int j = 0; j < 10; j++) {
        System.out.println(j);
    }
}

If I am to write a unit test to check the for loop was run 10 times. Is it possible to do this?

I was asked this question in an interview.

Aucun commentaire:

Enregistrer un commentaire