mardi 19 janvier 2021

how to test ArrayIndexOutOfBoundsException ? I have never tested with Junit, not sure what I have to do in this case

@Test(expected = ArrayIndexOutOfBoundsException.class) public void throwsArrayIndexException() {
    ...
}

I just have to test that if args[0]==0 in main method, ArrayIndexOutOfBoundsException is expected, I tried with if(args[0]==0){throw new ArrayIndexOutOfBoundException} but didn't work.. I appreciate your help! Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire