Permalink
Browse files

Fixed gh-318 (Empty message instead of null)

  • Loading branch information...
1 parent 2d13004 commit 1b809a4a2e914da039841ff3d1c457e8e5122ac3 @stefanbirkner committed Sep 18, 2011
@@ -11,6 +11,10 @@ public AssertionFailedError() {
}
public AssertionFailedError(String message) {
- super(message);
+ super(defaultString(message));
+ }
+
+ private static String defaultString(String message) {
+ return message == null ? "" : message;
}
}
@@ -18,6 +18,7 @@ public static Test suite() {
suite.addTestSuite(TestCaseTest.class);
suite.addTest(SuiteTest.suite()); // Tests suite building, so can't use automatic test extraction
suite.addTestSuite(TestListenerTest.class);
+ suite.addTestSuite(AssertionFailedErrorTest.class);
suite.addTestSuite(AssertTest.class);
suite.addTestSuite(TestImplementorTest.class);
suite.addTestSuite(NoArgTestCaseTest.class);
@@ -0,0 +1,23 @@
+package junit.tests.framework;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+
+public class AssertionFailedErrorTest extends TestCase {
+ private static final String ARBITRARY_MESSAGE= "arbitrary message";
+
+ public void testCreateErrorWithoutMessage() throws Exception {
+ AssertionFailedError error= new AssertionFailedError();
+ assertNull(error.getMessage());
+ }
+
+ public void testCreateErrorWithMessage() throws Exception {
+ AssertionFailedError error= new AssertionFailedError(ARBITRARY_MESSAGE);
+ assertEquals(ARBITRARY_MESSAGE, error.getMessage());
+ }
+
+ public void testCreateErrorWithoutMessageInsteadOfNull() throws Exception {
+ AssertionFailedError error= new AssertionFailedError(null);
+ assertEquals("", error.getMessage());
+ }
+}

0 comments on commit 1b809a4

Please sign in to comment.