diff --git a/hamcrest/src/main/java/org/hamcrest/MatcherAssert.java b/hamcrest/src/main/java/org/hamcrest/MatcherAssert.java index 049e1df3..bc001ebb 100644 --- a/hamcrest/src/main/java/org/hamcrest/MatcherAssert.java +++ b/hamcrest/src/main/java/org/hamcrest/MatcherAssert.java @@ -10,9 +10,11 @@ public static void assertThat(String reason, T actual, Matcher ma if (!matcher.matches(actual)) { Description description = new StringDescription(); description.appendText(reason) - .appendText("\nExpected: ") + .appendText(System.lineSeparator()) + .appendText("Expected: ") .appendDescriptionOf(matcher) - .appendText("\n but: "); + .appendText(System.lineSeparator()) + .appendText(" but: "); matcher.describeMismatch(actual, description); throw new AssertionError(description.toString()); diff --git a/hamcrest/src/test/java/org/hamcrest/MatcherAssertTest.java b/hamcrest/src/test/java/org/hamcrest/MatcherAssertTest.java index b57c4d77..8d88daa8 100644 --- a/hamcrest/src/test/java/org/hamcrest/MatcherAssertTest.java +++ b/hamcrest/src/test/java/org/hamcrest/MatcherAssertTest.java @@ -12,8 +12,9 @@ public final class MatcherAssertTest { includesDescriptionOfTestedValueInErrorMessage() { String expected = "expected"; String actual = "actual"; + String endLine = System.lineSeparator(); - String expectedMessage = "identifier\nExpected: \"expected\"\n but: was \"actual\""; + String expectedMessage = "identifier" + endLine + "Expected: \"expected\"" + endLine + " but: was \"actual\""; try { assertThat("identifier", actual, equalTo(expected)); @@ -30,8 +31,9 @@ public final class MatcherAssertTest { descriptionCanBeElided() { String expected = "expected"; String actual = "actual"; + String endLine = System.lineSeparator(); - String expectedMessage = "\nExpected: \"expected\"\n but: was \"actual\""; + String expectedMessage = endLine + "Expected: \"expected\"" + endLine + " but: was \"actual\""; try { assertThat(actual, equalTo(expected)); @@ -78,7 +80,8 @@ public void describeMismatch(Object item, Description mismatchDescription) { } }; - String expectedMessage = "\nExpected: Something cool\n but: Not cool"; + String endLine = System.lineSeparator(); + String expectedMessage = endLine + "Expected: Something cool" + endLine + " but: Not cool"; try { assertThat("Value", matcherWithCustomMismatchDescription);