I’m doing a simple assignment that reads user input from System.in, but then it suddenly occurred to me that the assignment requires me to create jUnit test cases to confirm that it works properly. So how can I simulate a user inserting input into System.in while sitting on a test case method?
I’m doing a simple assignment that reads user input from System.in , but then
Share
In your implementation do not use
System.indirectly, but rather use genericInputStream.This way in your test class you can use
ByteArrayInputStreamwith canned values.