First of all, if you already have the code written, and only now you're writing the test, it's not TDD.
Regarding your problem, one way to solve this is to have the InputStream
passed as a parameter to the constructor to the class you're testing, rather than hard-coding System.in
.
This will enable you to create an instance of the tested class with a mock InputStream
that generates whichever input you want.