I am trying learn Junit and i stumble up on this. at the moment i am trying to testing this part of my code
while (true) {
System.out.println("Enter Marks for Assingment B:");
try {
MarksB = Double.parseDouble(data.next());
if (MarksB<0||MarksB>50){
System.out.println("Please enter a number between 0-50");
}
else{
break;
}
} catch (NumberFormatException e) {
System.out.println("Please enter a valid number");
System.out.println(e);
}
}
Trying to Test this part of using Junit, but i can not figure out way to insert a string input MarksB varaible (double), This is the code iv written so far
@Test (expected = NumberFormatException.class)
public void testInvalidInput(){
double sum = Testing.add2Marks("string", 12);
}
Thanks in advance
Aucun commentaire:
Enregistrer un commentaire