How to test a method, that uses a Scanner? #448
Answered
by
bartfastiel
bartfastiel
asked this question in
Java
-
I want to test a method like this:
The method has no arguments / parameters. How can I define the "given"-part of my test? |
Beta Was this translation helpful? Give feedback.
Answered by
bartfastiel
Jan 11, 2023
Replies: 1 comment
-
Only test the logic, not the scanning of input. If you refactor your code like this:
Then you can test method |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
bartfastiel
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Only test the logic, not the scanning of input.
If you refactor your code like this:
Then you can test method
bla
with a usual unit-test.