Skip to content

Commit

Permalink
Polish AssertionsTests
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Jul 27, 2016
1 parent 6b97c1f commit d3580ba
Showing 1 changed file with 10 additions and 11 deletions.
Expand Up @@ -3057,31 +3057,30 @@ private static void expectAssertionFailedError() {
throw new AssertionError("Should have thrown an " + AssertionFailedError.class.getName()); throw new AssertionError("Should have thrown an " + AssertionFailedError.class.getName());
} }


private static void assertMessageEquals(AssertionFailedError ex, String msg) throws AssertionError { private static void assertMessageEquals(Throwable ex, String msg) throws AssertionError {
if (!msg.equals(ex.getMessage())) { if (!msg.equals(ex.getMessage())) {
throw new AssertionError( throw new AssertionError("Exception message should be [" + msg + "], but was [" + ex.getMessage() + "].");
"Message in AssertionFailedError should be [" + msg + "], but was [" + ex.getMessage() + "].");
} }
} }


private static void assertMessageEndsWith(AssertionFailedError ex, String msg) throws AssertionError { private static void assertMessageStartsWith(Throwable ex, String msg) throws AssertionError {
if (!ex.getMessage().endsWith(msg)) { if (!ex.getMessage().startsWith(msg)) {
throw new AssertionError( throw new AssertionError(
"Message in AssertionFailedError should end with [" + msg + "], but was [" + ex.getMessage() + "]."); "Exception message should start with [" + msg + "], but was [" + ex.getMessage() + "].");
} }
} }


private static void assertMessageStartsWith(AssertionFailedError ex, String msg) throws AssertionError { private static void assertMessageEndsWith(Throwable ex, String msg) throws AssertionError {
if (!ex.getMessage().startsWith(msg)) { if (!ex.getMessage().endsWith(msg)) {
throw new AssertionError( throw new AssertionError(
"Message in AssertionFailedError should start with [" + msg + "], but was [" + ex.getMessage() + "]."); "Exception message should end with [" + msg + "], but was [" + ex.getMessage() + "].");
} }
} }


private static void assertMessageContains(AssertionFailedError ex, String msg) throws AssertionError { private static void assertMessageContains(Throwable ex, String msg) throws AssertionError {
if (!ex.getMessage().contains(msg)) { if (!ex.getMessage().contains(msg)) {
throw new AssertionError( throw new AssertionError(
"Message in AssertionFailedError should contain [" + msg + "], but was [" + ex.getMessage() + "]."); "Exception message should contain [" + msg + "], but was [" + ex.getMessage() + "].");
} }
} }


Expand Down

0 comments on commit d3580ba

Please sign in to comment.