Raj*_*ami 3 java junit intellij-idea system-rules
我有一个比较两个字符串的JUnit测试:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = CDPlayerConfig.class)
public class CDPlayerTest {
@Rule
public final SystemOutRule log = new SystemOutRule().enableLog();
@Autowired
private CompactDisc cd;
@Autowired
private MediaPlayer player;
@Test
public void cdShouldNotBeNull() {
assertNotNull(cd);
}
@Test
public void play() {
player.play();
assertEquals("Playing title Sgt. Pepper's Lonely Hearts Club Band by artist The Beatles\n",
log.getLog());
}
}
Run Code Online (Sandbox Code Playgroud)
我org.junit.ComparisonFailure在第二次测试时遇到异常.但是,IntelliJ显示的内容是相同的.我错过了什么?
编辑:添加回预期字符串末尾的\n.
| 归档时间: |
|
| 查看次数: |
1215 次 |
| 最近记录: |