Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #514 from Tibor17/junit.bugs

TextListenerTest failed with unexpected elapsed time
  • Loading branch information...
commit 5849b6b4bbbd8e278f33312b292f774ac2c0e9fe 2 parents 30bc68c + ecaf372
@dsaff dsaff authored
Showing with 10 additions and 9 deletions.
  1. +10 −9 src/test/java/org/junit/tests/listening/TextListenerTest.java
View
19 src/test/java/org/junit/tests/listening/TextListenerTest.java
@@ -10,19 +10,21 @@
import org.junit.runner.JUnitCore;
import org.junit.tests.TestSystem;
+import static org.hamcrest.core.StringContains.containsString;
+import static org.hamcrest.core.IsNot.not;
+import static org.junit.Assert.assertThat;
+
public class TextListenerTest extends TestCase {
private JUnitCore runner;
private OutputStream results;
- private TextListener listener;
@Override
public void setUp() {
runner= new JUnitCore();
TestSystem system= new TestSystem();
results= system.outContents();
- listener= new TextListener(system);
- runner.addListener(listener);
+ runner.addListener(new TextListener(system));
}
public static class OneTest {
@@ -45,15 +47,14 @@ public void testError() throws Exception {
assertTrue(results.toString().indexOf(convert("\nThere was 1 failure:\n1) error(org.junit.tests.listening.TextListenerTest$ErrorTest)\njava.lang.Exception")) != -1);
}
- public static class Slow {
- @Test public void pause() throws InterruptedException {
- Thread.sleep(1000);
- }
+ public static class Time {
+ @Test public void time() {}
}
public void testTime() {
- runner.run(Slow.class);
- assertFalse(results.toString().contains("Time: 0"));
+ runner.run(Time.class);
+ assertThat(results.toString(), containsString("Time: "));
+ assertThat(results.toString(), not(containsString(convert("Time: \n"))));
}
private String convert(String string) {
Please sign in to comment.
Something went wrong with that request. Please try again.