How to test an interactive java application using cucumber and aruba
I have this Cucumber/Aruba scenario:
Scenario: Simple echo
Given I run `java -cp /bin Echo` interactively
When I type "something\n"
Then the output should contain "something"
To test this simple java program:
import java.util.*;
class Echo {
public static void main(String[] args) {
Scanner stdin = new Scanner(System.in);
System.out.println(stdin.next());
}
}
When I run the test it fails and I get the following error:
Then the output should contain "something"
expected "" to include "something" (RSpec::Expectations::ExpectationNotMetError)
features/cli.feature:15:in `Then the output should contain "something"'
When I try the same test with this ruby program:
puts gets
is all green...
Am I doing something wrong here?
Do have to use another method to read from standard input? is System.in used for the keyboard only?