dimanche 25 janvier 2015

Testing (junit) the default case in a switch statement?

I need to know how to test the default case in a switch statement with junit. I can't change the code itself and I'm trying for 100% coverage but I don't know how to test my default. Helps?



public Hello helloSwitch() {
Hello hi = Hello.A;
switch (this) {
case A:
hi = Hello.B;
break;
case B:
hi = Hello.C;
break;
case C:
hi = Hello.A;
break;
default:
hi = Hello.A;
break;
}


I had to modify the code a fair bit so sorry that it looks silly. I just need to know how to write a junit to test the default, I've tested everything else.


I can't change this code.


Edit: changed


Edit: This code isn't important I jut need to know how to write the unit test for the default


Aucun commentaire:

Enregistrer un commentaire