Why can't JUnit accept Console input from the user? #3766
Replies: 1 comment
-
JUnit doesn't block console input. I just ran your test and typed in "foo" and then ENTER, and this is the result:
You just need to figure out where the "console" is when you're running JUnit. In Eclipse IDE (where I ran this), there is a |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I understand that JUnit itself is all about unit testing, so it's designed to not accept input from the user.
I'd like to see the code that is structured to prevent me from getting console input, but where should I look?
Most references will tell you that you can use System.setIn() to test against standard input.
I don't want to test against standard input, I want to see where JUnit doesn't accept console input.
I also want to know how
public static void main(String[] args)
accepts Console input.To verify this, I compiled the following code and checked the Bytecode.
However, I couldn't find where it was blocking input to the console.
Beta Was this translation helpful? Give feedback.
All reactions