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