I gotta to test method that is responsible for taking input. It contains try/catch blocks. Should I unit test? If so, how to do it?
static String takeStringInput(Scanner input, String label) {
while (true) {
try {
System.out.println(label + ": ");
return input.next();
} catch (InputMismatchException e) {
System.out.println("Try again, bad input");
input.next();
}
}
}
Mocking Scanner is impossible as no possible to mock final class.