I need to run a code for given number of times. I'm wondering how to unit test this loop
public void executeCode(int iterations){
for (int i = 0; i < iterations; i++)
try {
callToCode(parms...);
} catch(Exception e) {
// handle exception
i--;
}
}
callToCode this method has 100% line coverage but one of the requirement it that this method get executed for given number of iterations.
I can have instance variable to track execution but what is the best way to unit test such loop?
I can only use Junit and not other library