This post is similar to: this
I have a console app that expects both user input and has responsive user output. I am writing some unit tests for it to make sure that the code works properly. I need to be able to make sure that the output and input for it are what I expect them to be.
Essentially, I have a main method being tested that asks for a file or input. In my test, I use System.setOut
and System.setIn
to set those to context.mock versions of PrintStream and InputStream objects respectively. I don't care about what System.out.println
calls get made until I have to test the actual processing of the program data, when it outputs its results to the console. So to summarize:
Here's my source being tested (something close, I trimmed much out): http://ideone.com/rptC0
Here's what I have in my mocking procedure: http://ideone.com/VkvqM
And here's the exception that I'm getting: ideone.com/OEOS8
As you can clearly see in my expectations, I'm explicitly saying that I was planning to print the exact same string out, and I specified that in my expectations. But the exception says that it was unexpected. I don't understand...
Word
andWordFrequency
) nor correct -main
doesn't compile because it uses type 'bool' and calls an undefined methodinputReadFailure
– DNA