0
這裏是我的測試:失敗的assertEquals兩個看似相同的字符串
@Test
public void testAddPaperConfirm()
{
String input = "P\n" +
"The Life of Geoff the Platypus";
InputStream testInput = new ByteArrayInputStream(input.getBytes());
System.setOut(new PrintStream(testOutput));
System.setIn(testInput);
testReviewSystem.main(new String[] {});
assertEquals(testOutput.toString(), "What do you want to do?\n" +
"O = Overview, P = Add Paper, R = Add Review, [num] = Detail of that paper, X = exit\n" +
"What is the title of the paper?\n" +
"[Paper added]\n"
+ "What do you want to do?\n" +
"O = Overview, P = Add Paper, R = Add Review, [num] = Detail of that paper, X = exit\n");
}
提示:遠離assertEquals。只要看看它的大哥** assertThat **。比較價值和告訴你什麼是不匹配通常會更好。 – GhostCat
您的測試缺少一些可以讓我們嘗試重現問題的重要信息。您是否可以更新以包含它? – Krease
也許實際輸出使用'\ r \ n'換行符? – Andreas