Examples of EachTestNotifier


Examples of org.junit.internal.runners.model.EachTestNotifier

    public void run( RunNotifier notifier ) {
        for ( Scenario scenario : scenarios ) {
            Description childDescription = Description.createTestDescription( getClass(),
                                                                              scenario.getName() );
            descr.addChild( childDescription );
            EachTestNotifier eachNotifier = new EachTestNotifier( notifier,
                                                                  childDescription );
            try {
                eachNotifier.fireTestStarted();

                //If a KieSession is not available, fail fast
                if ( ksession == null ) {
                    throw new NullKieSessionException( "Unable to get a Session to run tests. Check the project for build errors." );

                } else {

                    final ScenarioRunner runner = new ScenarioRunner( ksession,
                                                                      maxRuleFirings );
                    runner.run( scenario );
                    if ( !scenario.wasSuccessful() ) {
                        StringBuilder builder = new StringBuilder();
                        for ( String message : scenario.getFailureMessages() ) {
                            builder.append( message ).append( "\n" );
                        }
                        eachNotifier.addFailedAssumption( new AssumptionViolatedException( builder.toString() ) );
                    }

                    // FLUSSSSSH!
                    for (FactHandle factHandle : ksession.getFactHandles()) {
                        ksession.delete(factHandle);
                    }
                }
            } catch ( Throwable t ) {
                eachNotifier.addFailure( t );
            } finally {
                // has to always be called as per junit docs
                eachNotifier.fireTestFinished();
            }
        }
    }
View Full Code Here

Examples of org.junit.internal.runners.model.EachTestNotifier

    }

    @Override
    public void run( RunNotifier notifier ) {
        Description description = descr.getChildren().get( 0 );
        EachTestNotifier eachNotifier = new EachTestNotifier( notifier, description );
        try {
            eachNotifier.fireTestStarted();
            ScenarioRunner runner = new ScenarioRunner( ksession );
            runner.run( scenario );
            if ( !scenario.wasSuccessful() ) {
                StringBuilder builder = new StringBuilder();
                for ( String message : scenario.getFailureMessages() ) {
                    builder.append( message ).append( "\n" );
                }
                eachNotifier.addFailedAssumption( new AssumptionViolatedException( builder.toString() ) );
            }
        } catch ( Throwable t ) {
            eachNotifier.addFailure( t );
        } finally {
            // has to always be called as per junit docs
            eachNotifier.fireTestFinished();
        }
    }
View Full Code Here

Examples of org.junit.internal.runners.model.EachTestNotifier

    @Override
    protected void runChild(FrameworkMethod method, RunNotifier notifier)
    {
        Description description = describeChild(method);
        EachTestNotifier eachTestNotifier = new EachTestNotifier(notifier, description);

        if (method.getAnnotation(Ignore.class) != null)
        {
            eachTestNotifier.fireTestIgnored();
            return;
        }

        eachTestNotifier.fireTestStarted();

        try
        {
            methodBlock(method).evaluate();
        }
        catch (AssumptionViolatedException e)
        {
            eachTestNotifier.addFailedAssumption(e);
        }
        catch (ContainerNotStartedException e)
        {
            LOGGER.fine("In this step the container isn't started -> test result is ignored for now. " +
                    "Please make sure that the test gets executed in a later phase.");
        }
        catch (Throwable e)
        {
            eachTestNotifier.addFailure(e);
        }
        finally
        {
            eachTestNotifier.fireTestFinished();
        }
    }
View Full Code Here

Examples of org.junit.internal.runners.model.EachTestNotifier

            return childrenInvoker(notifier);
        }

        @Override
        protected void runChild(FrameworkMethod method, RunNotifier notifier) {
            EachTestNotifier eachNotifier= makeNotifier(method, notifier);
            if (method.getAnnotation(Ignore.class) != null) {
                eachNotifier.fireTestIgnored();
                return;
            }

            eachNotifier.fireTestStarted();
            try {
                for (int i=0; i<numRuns; i++) {
                    if (logger.isLoggable(Level.INFO)) {
                        logger.log(Level.INFO, "--Starting run "+(i+1)+" of "+method.getName()+"--");
                    }
                    methodBlock(method).evaluate();
                }
            } catch (AssumptionViolatedException e) {
                eachNotifier.addFailedAssumption(e);
            } catch (Throwable e) {
                eachNotifier.addFailure(e);
            } finally {
                eachNotifier.fireTestFinished();
            }
        }
View Full Code Here

Examples of org.junit.internal.runners.model.EachTestNotifier

            }
        }
        protected EachTestNotifier makeNotifier(FrameworkMethod method,
                                                RunNotifier notifier) {
            Description description= describeChild(method);
            return new EachTestNotifier(notifier, description);
        }
View Full Code Here

Examples of org.junit.internal.runners.model.EachTestNotifier

        super(klass);
    }

    @Override
    protected void runChild(FrameworkMethod method, RunNotifier notifier) {
        EachTestNotifier eachNotifier= makeNotifier(method, notifier);
        if (method.getAnnotation(Ignore.class) != null) {
            eachNotifier.fireTestIgnored();
            return;
        }

        eachNotifier.fireTestStarted();
        try {
            for (int i=0; i<numRuns; i++) {
                if (logger.isLoggable(Level.INFO)) {
                    logger.log(Level.INFO, "--Starting run "+(i+1)+" of "+method.getName()+"--");
                }
                methodBlock(method).evaluate();
            }
        } catch (AssumptionViolatedException e) {
            eachNotifier.addFailedAssumption(e);
        } catch (Throwable e) {
            eachNotifier.addFailure(e);
        } finally {
            eachNotifier.fireTestFinished();
        }
    }
View Full Code Here

Examples of org.junit.internal.runners.model.EachTestNotifier

        }
    }
    protected EachTestNotifier makeNotifier(FrameworkMethod method,
                                            RunNotifier notifier) {
        Description description= describeChild(method);
        return new EachTestNotifier(notifier, description);
    }
View Full Code Here

Examples of org.junit.internal.runners.model.EachTestNotifier

    public void run( RunNotifier notifier ) {
         for(Scenario scenario : scenarios) {
             Description childDescription = Description.createTestDescription(getClass(),
                    scenario.getName());
             descr.addChild(childDescription);
            EachTestNotifier eachNotifier = new EachTestNotifier( notifier, childDescription );
            try {
                eachNotifier.fireTestStarted();
                ScenarioRunner runner = new ScenarioRunner( ksession );
                runner.run( scenario );
                if ( !scenario.wasSuccessful() ) {
                    StringBuilder builder = new StringBuilder();
                    for ( String message : scenario.getFailureMessages() ) {
                        builder.append( message ).append( "\n" );
                    }
                    eachNotifier.addFailedAssumption( new AssumptionViolatedException( builder.toString() ) );
                }
            } catch ( Throwable t ) {
                eachNotifier.addFailure( t );
            } finally {
                // has to always be called as per junit docs
                eachNotifier.fireTestFinished();
            }       
      }
    }
View Full Code Here

Examples of org.junit.internal.runners.model.EachTestNotifier

        }
    }

    private void runInTransaction(FrameworkMethod method, RunNotifier notifier) {
        UserTransaction tx = null;
        EachTestNotifier eachNotifier = makeNotifier(method, notifier);
        if (method.getAnnotation(Ignore.class) != null) {
            eachNotifier.fireTestIgnored();
            return;
        }

        eachNotifier.fireTestStarted();
        try {
            InitialContext ctx = new InitialContext();
            tx = (UserTransaction) ctx.lookup("java:comp/UserTransaction");
            tx.begin();
            methodBlock(method).evaluate();
        }
        catch (NamingException exc) {
            eachNotifier.addFailure(exc);
        }
        catch (NotSupportedException exc) {
            eachNotifier.addFailure(exc);
        }
        catch (SystemException exc) {
            eachNotifier.addFailure(exc);
        }
        catch (AssumptionViolatedException e) {
            eachNotifier.addFailedAssumption(e);
        }
        // CHECKSTYLE:SKIP : base class API
        catch (Throwable e) {
            eachNotifier.addFailure(e);
        }
        finally {
            rollback(tx, eachNotifier);
            eachNotifier.fireTestFinished();
        }
    }
View Full Code Here

Examples of org.junit.internal.runners.model.EachTestNotifier

        return (method.getAnnotation(Transactional.class) != null) || transactionalClass;
    }

    private EachTestNotifier makeNotifier(FrameworkMethod method, RunNotifier notifier) {
        Description description = describeChild(method);
        return new EachTestNotifier(notifier, 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.