From 4ccdf9c959017cd6a38d1201ef1097eb06203c3f Mon Sep 17 00:00:00 2001 From: Mike Cifelli Date: Sun, 12 Nov 2017 17:19:30 -0500 Subject: [PATCH] Refactor tests to use modern assertions --- pom.xml | 6 ++++++ test/testutil/TestUtilities.java | 17 ++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 34b9a8a..9a6b388 100644 --- a/pom.xml +++ b/pom.xml @@ -69,6 +69,12 @@ 1.16.1 test + + org.hamcrest + hamcrest-all + test + 1.3 + UTF-8 diff --git a/test/testutil/TestUtilities.java b/test/testutil/TestUtilities.java index 6220bf4..94e6c2a 100644 --- a/test/testutil/TestUtilities.java +++ b/test/testutil/TestUtilities.java @@ -2,10 +2,10 @@ package testutil; import static error.ErrorManager.Severity.ERROR; import static function.builtin.EVAL.eval; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.isEmptyOrNullString; +import static org.hamcrest.Matchers.not; +import static org.junit.Assert.assertThat; import static sexpression.Nil.NIL; import java.io.ByteArrayInputStream; @@ -85,17 +85,16 @@ public final class TestUtilities { } public static void assertSExpressionsMatch(SExpression one, SExpression two) { - assertEquals(one.toString(), two.toString()); + assertThat(one.toString(), is(two.toString())); } public static void assertSExpressionsDoNotMatch(SExpression one, SExpression two) { - assertNotEquals(one.toString(), two.toString()); + assertThat(one.toString(), not(two.toString())); } public static void assertIsErrorWithMessage(LispException e) { - assertEquals(ERROR, e.getSeverity()); - assertNotNull(e.getMessage()); - assertTrue(e.getMessage().length() > 0); + assertThat(e.getSeverity(), is(ERROR)); + assertThat(e.getMessage(), not(isEmptyOrNullString())); } }