All,
I have written a PhoneBook application in Java that is command line based. The application basically asks for some details of user like Name, Age, Address and p
The library System Rules provides the rule TextFromStandardInputStream for simulating input in JUnit tests.
public class YourAppTest {
@Rule
public TextFromStandardInputStream systemInMock = emptyStandardInputStream();
@Test
public void test() {
systemInMock.provideText("name\nsomething else\n");
YourApp.main();
//assertSomething
}
}
For details have a look at the System Rules documentation.