In our application, we expect user input within a Thread as follows :
Thread
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
Replace it for the duration of your test:
String data = "the text you want to send"; InputStream testInput = new ByteArrayInputStream( data.getBytes("UTF-8") ); InputStream old = System.in; try { System.setIn( testInput ); ... } finally { System.setIn( old ); }