0
如何測試用黃瓜和阿魯巴如何用黃瓜和阿魯巴
一個交互式的Java應用程序來測試一個交互的Java應用程序,我有這樣的黃瓜/阿魯巴場景:
Scenario: Simple echo
Given I run `java -cp /bin Echo` interactively
When I type "something\n"
Then the output should contain "something"
爲了測試這個簡單的Java程序:
import java.util.*;
class Echo {
public static void main(String[] args) {
Scanner stdin = new Scanner(System.in);
System.out.println(stdin.next());
}
}
當我運行測試失敗,我得到以下錯誤:
Then the output should contain "something"
expected "" to include "something" (RSpec::Expectations::ExpectationNotMetError)
features/cli.feature:15:in `Then the output should contain "something"'
當我試着使用這個Ruby程序相同的測試:
puts gets
全部是綠色......
難道我做錯了什麼嗎?
是否必須使用另一種方法從標準輸入讀取? System.in僅用於鍵盤嗎?
都嘗試的事情,仍然沒有工作:( – victrnava 2011-03-29 12:21:27
所以的System.out.println(「東西」)仍然沒有得到回升並讓你的測試通過?聽起來像aruba沒有拿起Java輸出,它是否從System.err.println(「Something」)中獲取內容? – Clinton 2011-03-30 00:27:53