@Test(timeout=3000) public void testDoubleExecution(){ RuntimeSettings.mockSystemIn = true; String data = "Hello World!"; SystemInUtil.getInstance().initForTestCase(); SystemInUtil.addInputLine(data); Scanner scanner = new Scanner(System.in); String first = scanner.nextLine(); scanner.close(); Assert.assertEquals(data, first); //now add the same again SystemInUtil.addInputLine(data); scanner = new Scanner(System.in); String second = scanner.nextLine(); scanner.close(); Assert.assertEquals(data, second); }