diff --git a/build.xml b/build.xml index bcb3aa3c3ded..feef92f12902 100644 --- a/build.xml +++ b/build.xml @@ -207,12 +207,14 @@ - + + + diff --git a/src/main/java/org/junit/runner/notification/SynchronizedRunListener.java b/src/main/java/org/junit/runner/notification/SynchronizedRunListener.java index c8db313d3728..d6f00e1f9f5b 100644 --- a/src/main/java/org/junit/runner/notification/SynchronizedRunListener.java +++ b/src/main/java/org/junit/runner/notification/SynchronizedRunListener.java @@ -106,6 +106,6 @@ public boolean equals(Object other) { @Override public String toString() { - return fListener.toString(); + return fListener.toString() + " (with synchronization wrapper)"; } } diff --git a/src/test/java/org/junit/runner/notification/ConcurrentRunNotifierTest.java b/src/test/java/org/junit/runner/notification/ConcurrentRunNotifierTest.java index b5bee7c25616..3406ed91150f 100644 --- a/src/test/java/org/junit/runner/notification/ConcurrentRunNotifierTest.java +++ b/src/test/java/org/junit/runner/notification/ConcurrentRunNotifierTest.java @@ -59,8 +59,8 @@ public void run() { fNotifier.removeListener(listener1); fNotifier.removeListener(listener2); - assertThat(listener1.fTestStarted.get(), is(4)); - assertThat(listener2.fTestStarted.get(), is(4)); + assertThat(listener1.fTestStarted.get(), is(numParallelTests)); + assertThat(listener2.fTestStarted.get(), is(numParallelTests)); } private static class ExaminedListener extends RunListener { diff --git a/src/test/java/org/junit/runner/notification/SynchronizedRunListenerTest.java b/src/test/java/org/junit/runner/notification/SynchronizedRunListenerTest.java index bfdeea34fb22..a65648b03043 100644 --- a/src/test/java/org/junit/runner/notification/SynchronizedRunListenerTest.java +++ b/src/test/java/org/junit/runner/notification/SynchronizedRunListenerTest.java @@ -81,6 +81,11 @@ public NamedListener(String name) { fName = name; } + @Override + public String toString() { + return "NamedListener"; + } + @Override public int hashCode() { return fName.hashCode(); @@ -124,7 +129,15 @@ public void namedListenerCorrectlyImplementsEqualsAndHashCode() { assertEquals(listener1.hashCode(), listener2.hashCode()); assertNotEquals(listener1.hashCode(), listener3.hashCode()); } - + + @Test + public void toStringDelegates() { + NamedListener listener = new NamedListener("blue"); + + assertEquals("NamedListener", listener.toString()); + assertEquals("NamedListener (with synchronization wrapper)", new SynchronizedRunListener(listener).toString()); + } + @Test public void equalsDelegates() { NamedListener listener1 = new NamedListener("blue");