I'm trying to test a console application that uses jline for handling interaction with the user.
I'm starting the application using ProcessBuilder which gives me access to the application's:
I was expecting to use a workflow similar to this:
- Start Application
- Read Output until I see the application's prompt
>
- Send Input for my test case, e.g.
login
- Read Output until I see the expect response, e.g.
Username:
- and so on
However, the test just freezes. Stepping through the code, it appears that jline is freezing on JNI calls to _getch on Windows. I'm guessing that the problem is because I am running Java from ProcessBuilder which is headless so there is no console and that is confusing windows. Setting -Djline.terminal=jline.UnsupportedTerminal
as per the Jline docs doesn't help either.
I've found a thread discussing Python pexpect for testing a (non-java) readline application.
Question: how can I test a jline based application using just java tools?