Let\'s suppose I have a program with a main method that uses the java.util.Scanner
class to receive user input.
import java.util.Scanner;
publ
You can redirect System.out, System.in, and System.err like this:
System.setOut(new PrintStream(new FileOutputStream("output")));
System.setErr(new PrintStream(new FileOutputStream("error")));
System.setIn(new FileInputStream("input"));
So in you unit test you can setup this redirection and run your class.