AssertEquals(String, String) ComparisonFailure when contents are identical

前端 未结 2 541
刺人心
刺人心 2020-12-18 21:33

I\'m facing the following scenario:

I have an app that spits everything out to the STDOUT (simple company test) and I\'m trying to JUnit this.

My problem is,

2条回答
  •  -上瘾入骨i
    2020-12-18 21:59

    You can use AssertJ "isEqualToNormalizingNewline" as in:

    import static org.assertj.core.api.Assertions.assertThat;
    
    ...
    
    @Test
    public void ingoreLineEndingCharacterTest() {
        assertThat("First Line\nSecond Line\n").isEqualToNormalizingNewlines("First Line\r\nSecond Line\r\n");
    }
    

提交回复
热议问题