Package org.junit.runner

Examples of org.junit.runner.JUnitCore.addListener()


            @Override
            public void testRunStarted(Description description) throws Exception {
                log += "first ";
            }
        });
        core.addListener(new RunListener() {
            @Override
            public void testRunStarted(Description description) throws Exception {
                log += "second ";
            }
        });
View Full Code Here


    }

    @Test(expected = Error.class)
    public void failingListener() {
        JUnitCore runner = new JUnitCore();
        runner.addListener(new ErrorListener());
        runner.run(OneTest.class);
    }

    class ExceptionListener extends ErrorListener {
        @Override
View Full Code Here

    }

    @Test
    public void reportsFailureOfListener() {
        JUnitCore core = new JUnitCore();
        core.addListener(new ExceptionListener());

        count = 0;
        Result result = core.run(OneTest.class);
        assertEquals(1, count);
        assertEquals(1, result.getFailureCount());
View Full Code Here

    return new JUnit4TestAdapter(AllTests.class);
  }

  public static void main(String... args) throws InitializationError {
    JUnitCore core = new JUnitCore();
    core.addListener(new TextListener());
    core.run(AllTests.class);
  }
}
View Full Code Here

  }

  public static void main(String... args) throws InitializationError {
    JUnitCore core = new JUnitCore();
    // use for categories special listener, give some statistics
    core.addListener(new CategoryTextListener(System.out));
    core.run(PrerequisiteCategorySample.class);
  }
}
View Full Code Here

    }
  }
  @Test public void notifyListenersInTheOrderInWhichTheyAreAdded() {
    JUnitCore core= new JUnitCore();
    log= "";
    core.addListener(new RunListener() {
      @Override
      public void testRunStarted(Description description) throws Exception {
        log+="first ";
      }
    });
View Full Code Here

      @Override
      public void testRunStarted(Description description) throws Exception {
        log+="first ";
      }
    });
    core.addListener(new RunListener() {
      @Override
      public void testRunStarted(Description description) throws Exception {
        log+="second ";
      }
    });
View Full Code Here

    @Test public void nothing() {}
  }
 
  @Test(expected=Error.class) public void failingListener() {
    JUnitCore runner= new JUnitCore();
    runner.addListener(new ErrorListener());
    runner.run(OneTest.class);
  }
 
  class ExceptionListener extends ErrorListener {
    @Override
View Full Code Here

    }
  }
 
  @Test public void removeFailingListeners() {
    JUnitCore core= new JUnitCore();
    core.addListener(new ExceptionListener());
   
    count= 0;
    Result result= core.run(OneTest.class);
    assertEquals(1, count);
    assertEquals(1, result.getFailureCount());
View Full Code Here

  }

  @Test public void callWithSorter() throws InitializationError {
    JUnitCore core = new JUnitCore();
    final List<Description> descs = new ArrayList<Description>();
    core.addListener(new TextListener() {
      @Override
      public void testFinished(Description description) throws Exception {
        descs.add(description);
        //super.testFinished(description);
      }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.