Examples of RunListener


Examples of org.junit.runner.notification.RunListener

    }
  }
  @Test public void notifyListenersInTheOrderInWhichTheyAreAdded() {
    JUnitCore core= new JUnitCore();
    log= "";
    core.addListener(new RunListener() {
      @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

Examples of org.junit.runner.notification.RunListener

    }
  }
 
  @Test public void testListener() throws Exception {
    JUnitCore runner= new JUnitCore();
    RunListener listener= new RunListener() {
      @Override
      public void testStarted(Description description) {
        assertEquals(Description.createTestDescription(OneTest.class, "testOne"),
            description);
        count++;
View Full Code Here

Examples of org.junit.runner.notification.RunListener

  }
 
  @Test public void testFinished() {
    JUnitCore runner= new JUnitCore();
    wasRun= false;
    RunListener listener= new MyListener() {
      @Override
      public void testFinished(Description description) {
        wasRun= true;
      }
    };
View Full Code Here

Examples of org.junit.runner.notification.RunListener

     
      // only print iteration info if the user requested more than one iterations
      final boolean verbose = VERBOSE && TEST_ITER > 1;
     
      final int currentIter[] = new int[1];
      arg1.addListener(new RunListener() {
        @Override
        public void testFailure(Failure failure) throws Exception {
          if (verbose) {
            System.out.println("\nNOTE: iteration " + currentIter[0] + " failed! ");
          }
View Full Code Here

Examples of org.junit.runner.notification.RunListener

        timedRun( NUMTESTS, result, realClasses, jUnitCore, computer );
    }

    private JUnitCore getJunitCore( Result result )
    {
        RunListener listener = result.createListener();
        JUnitCore jUnitCore = new JUnitCore();
        jUnitCore.addListener( listener );
        return jUnitCore;
    }
View Full Code Here

Examples of org.junit.runner.notification.RunListener

    extends TestCase
{
    public void testTestRunStarted()
        throws Exception
    {
        RunListener jUnit4TestSetReporter =
            new JUnitCoreRunListener( new MockReporter(), new HashMap<String, TestSet>() );
        JUnitCore core = new JUnitCore();
        core.addListener( jUnit4TestSetReporter );
        Result result = core.run( new Computer(), STest1.class, STest2.class );
        core.removeListener( jUnit4TestSetReporter );
View Full Code Here

Examples of org.junit.runner.notification.RunListener

    }

    public void testFailedAssumption()
        throws Exception
    {
        RunListener jUnit4TestSetReporter =
            new JUnitCoreRunListener( new MockReporter(), new HashMap<String, TestSet>() );
        JUnitCore core = new JUnitCore();
        core.addListener( jUnit4TestSetReporter );
        Result result = core.run( new Computer(), TestWithAssumptionFailure.class );
        core.removeListener( jUnit4TestSetReporter );
View Full Code Here

Examples of org.junit.runner.notification.RunListener

{
    @Test
    public void testTestStarted()
        throws Exception
    {
        RunListener jUnit4TestSetReporter = new JUnit4RunListener( new MockReporter() );
        Runner junitTestRunner = Request.classes( "abc", STest1.class, STest2.class ).getRunner();
        RunNotifier runNotifier = new RunNotifier();
        runNotifier.addListener( jUnit4TestSetReporter );
        junitTestRunner.run( runNotifier );
    }
View Full Code Here

Examples of org.junit.runner.notification.RunListener

    @Test
    public void testParallelInvocations()
        throws Exception
    {
        final MockReporter reporter = new MockReporter();
        final RunListener jUnit4TestSetReporter = new JUnit4RunListener( reporter );
        final CountDownLatch countDownLatch = new CountDownLatch( 1 );
        final Description testSomething = Description.createTestDescription( STest1.class, "testSomething" );
        final Description testSomething2 = Description.createTestDescription( STest2.class, "testSomething2" );

        jUnit4TestSetReporter.testStarted( testSomething );

        new Thread( new Runnable()
        {
            public void run()
            {
                try
                {
                    jUnit4TestSetReporter.testStarted( testSomething2 );
                    jUnit4TestSetReporter.testFailure( new Failure( testSomething2, new AssertionError( "Fud" ) ) );
                    jUnit4TestSetReporter.testFinished( testSomething2 );
                    countDownLatch.countDown();
                }
                catch ( Exception e )
                {
                    throw new RuntimeException( e );
                }
            }
        } ).start();

        countDownLatch.await();
        jUnit4TestSetReporter.testFinished( testSomething );

        Assert.assertEquals( "Failing tests", 1, reporter.getTestFailed() );
        Assert.assertEquals( "Succeeded tests", 1, reporter.getTestSucceeded() );
    }
View Full Code Here

Examples of org.junit.runner.notification.RunListener

            return result;
        }

        for ( String thisListenerName : listenerProperty.split( "," ) )
        {
            RunListener customRunListener =
                (RunListener) ReflectionUtils.instantiate( Thread.currentThread().getContextClassLoader(),
                                                           thisListenerName );
            result.add( customRunListener );
        }
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.