I'm new to JUnit and we got a simple Insurance program that we refactored and broke into some methods in order to test them using JUnit. But I have no idea how I should go about testing a void method like this:
private static void belowAge() {
basicInsurance += surcharge;
System.out.println("Additional surcharge " + surcharge);
System.out.print("\nHow many accidents did you have? ");
int accidents = scan2.nextInt();
switch (accidents) {
case 0:
System.out.println("No surcharge");
System.out.println("Total amount to pay: " + basicInsurance);
break;
case 1:
System.out.println(
"Additional surcharge for accident: " + 50
+ " \ntotal amount to pay: " + (basicInsurance + 50)); // Pay 650
break;
case 2:
System.out.println(
"Additional surcharge for accident: " + 125
+ " \ntotal amount to pay: " + (basicInsurance + 125)); // Pay 725
break;
case 3:
System.out.println(
"Additional surcharge for accident: " + 225
+ " \ntotal amount to pay: " + (basicInsurance + 225)); // Pay 825
break;
case 4:
System.out.println(
"Additional surcharge for accident: " + 375
+ " \ntotal amount to pay: " + (basicInsurance + 375)); // 975
break;
case 5:
System.out.println(
"Additional surcharge for accident: " + 575
+ " \ntotal amount to pay: " + (basicInsurance + 575)); // 1175
break;
}