Package org.apache.maven.surefire.report

Examples of org.apache.maven.surefire.report.ReporterFactory


    public RunResult invoke( Object forkTestSet )
        throws TestSetFailedException, ReporterException
    {
        final String message = "Concurrency config is " + jUnitCoreParameters.toString() + "\n";
        final ReporterFactory reporterFactory = providerParameters.getReporterFactory();

        final ConsoleLogger consoleLogger = providerParameters.getConsoleLogger();
        consoleLogger.info( message );

        Filter filter = jUnit48Reflector.isJUnit48Available() ? createJUnit48Filter() : null;

        if ( testsToRun == null )
        {
            testsToRun = forkTestSet == null ? getSuitesAsList( filter ) : TestsToRun.fromClass( (Class) forkTestSet );
        }

        if ( testsToRun.size() == 0 )
        {
            filter = null;
        }

        final Map<String, TestSet> testSetMap = new ConcurrentHashMap<String, TestSet>();

        RunListener listener = ConcurrentReporterManager.createInstance( testSetMap, reporterFactory,
                                                                         jUnitCoreParameters.isParallelClasses(),
                                                                         jUnitCoreParameters.isParallelBoth(),
                                                                         consoleLogger );

        ConsoleOutputCapture.startCapture( (ConsoleOutputReceiver) listener );

        org.junit.runner.notification.RunListener jUnit4RunListener = new JUnitCoreRunListener( listener, testSetMap );
        customRunListeners.add( 0, jUnit4RunListener );

        JUnitCoreWrapper.execute( testsToRun, jUnitCoreParameters, customRunListeners, filter );
        return reporterFactory.close();
    }
View Full Code Here


        if ( testsToRun == null )
        {
            testsToRun = forkTestSet == null ? scanClassPath() : TestsToRun.fromClass( (Class) forkTestSet );
        }

        ReporterFactory reporterFactory = providerParameters.getReporterFactory();
        final RunListener reporter = reporterFactory.createReporter();
        ConsoleOutputCapture.startCapture( (ConsoleOutputReceiver) reporter );

        final String smClassName = System.getProperty( "surefire.security.manager" );
        if ( smClassName != null )
        {
            SecurityManager securityManager =
                (SecurityManager) ReflectionUtils.instantiate( this.getClass().getClassLoader(), smClassName );
            System.setSecurityManager( securityManager );
        }

        for ( Iterator iter = testsToRun.iterator(); iter.hasNext(); )
        {
            Class clazz = (Class) iter.next();
            SurefireTestSet surefireTestSet = createTestSet( clazz );
            executeTestSet( surefireTestSet, reporter, testClassLoader );
        }

        return reporterFactory.close();
    }
View Full Code Here

    public RunResult invoke( Object forkTestSet )
        throws TestSetFailedException, ReporterException
    {

        final ReporterFactory reporterFactory = providerParameters.getReporterFactory();

        if ( isTestNGXmlTestSuite( testRequest ) )
        {
            TestNGXmlTestSuite testNGXmlTestSuite = getXmlSuite();
            testNGXmlTestSuite.locateTestSets( testClassLoader );
            if ( forkTestSet != null && testRequest == null )
            {
                testNGXmlTestSuite.execute( (String) forkTestSet, reporterFactory );
            }
            else
            {
                testNGXmlTestSuite.execute( reporterFactory );
            }
        }
        else
        {
            if ( testsToRun == null )
            {
                testsToRun = forkTestSet == null ? scanClassPath() : TestsToRun.fromClass( (Class) forkTestSet );
            }
            TestNGDirectoryTestSuite suite = getDirectorySuite();
            suite.execute( testsToRun, reporterFactory );
        }

        return reporterFactory.close();
    }
View Full Code Here

            testsToRun = forkTestSet == null ? scanClassPath() : TestsToRun.fromClass( (Class<?>) forkTestSet );
        }

        upgradeCheck();

        final ReporterFactory reporterFactory = providerParameters.getReporterFactory();

        final RunListener reporter = reporterFactory.createReporter();

        ConsoleOutputCapture.startCapture( (ConsoleOutputReceiver) reporter );

        JUnit4RunListener jUnit4TestSetReporter = new JUnit4RunListener( reporter );

        Result result = new Result();
        RunNotifier runNotifer = getRunNotifer( jUnit4TestSetReporter, result, customRunListeners );

        runNotifer.fireTestRunStarted( null );

        for ( Class<?> clazz : testsToRun.getLocatedClasses() )
        {
            executeTestSet( clazz, reporter, runNotifer );
        }

        runNotifer.fireTestRunFinished( result );

        JUnit4RunListener.rethrowAnyTestMechanismFailures( result );

        closeRunNotifer( jUnit4TestSetReporter, customRunListeners );

        return reporterFactory.close();
    }
View Full Code Here

    @Test
    public void surefireIsConfused_ByMultipleIgnore_OnClassLevel()
        throws Exception
    {
        ReporterFactory reporterFactory = FileReporterFactory.defaultNoXml();
        BaseProviderFactory providerParameters = new BaseProviderFactory( reporterFactory, true );
        ConsoleLogger consoleLogger = new DefaultConsoleReporter( System.out );

        providerParameters.setReporterConfiguration( new ReporterConfiguration( new File( "" ), false ) );
        Properties junitProps = new Properties();
        junitProps.put( ProviderParameterNames.PARALLEL_PROP, "none" );

        JUnitCoreParameters jUnitCoreParameters = new JUnitCoreParameters( junitProps );

        final Map<String, TestSet> testSetMap = new ConcurrentHashMap<String, TestSet>();

        RunListener listener =
            ConcurrentReporterManager.createInstance( testSetMap, reporterFactory, false, false, consoleLogger );

        TestsToRun testsToRun = new TestsToRun( Arrays.<Class<?>>asList( TestClassTest.class ) );

        org.junit.runner.notification.RunListener jUnit4RunListener = new JUnitCoreRunListener( listener, testSetMap );

        List<org.junit.runner.notification.RunListener> customRunListeners =
            new ArrayList<org.junit.runner.notification.RunListener>();
        customRunListeners.add( 0, jUnit4RunListener );

        JUnitCoreWrapper.execute( testsToRun, jUnitCoreParameters, customRunListeners, null );

        RunResult result = reporterFactory.close();

        Assert.assertEquals( "JUnit should report correctly number of test ran(Finished)", 1,
                             result.getCompletedCount() );

    }
View Full Code Here

    }

    public Result run( boolean parallelClasses, Class<?>... classes )
        throws TestSetFailedException, ExecutionException
    {
        ReporterFactory reporterManagerFactory = FileReporterFactory.defaultNoXml();

        final HashMap<String, TestSet> classMethodCounts = new HashMap<String, TestSet>();
        RunListener reporter =
            ConcurrentReporterManager.createInstance( classMethodCounts, reporterManagerFactory, parallelClasses, false,
                                                      new DefaultConsoleReporter( System.out ) );
        ConsoleOutputCapture.startCapture( (ConsoleOutputReceiver) reporter );

        JUnitCoreRunListener runListener = new JUnitCoreRunListener( reporter, classMethodCounts );
        JUnitCore junitCore = new JUnitCore();

        junitCore.addListener( runListener );
        final Result run = junitCore.run( computer, classes );
        junitCore.removeListener( runListener );
        reporterManagerFactory.close();
        if ( computer instanceof ConfigurableParallelComputer )
        {
            ( (ConfigurableParallelComputer) computer ).close();
        }
        return run;
View Full Code Here

    }

    private void runClasses( int success, int ignored, int failure, Class<?>... classes )
        throws TestSetFailedException
    {
        ReporterFactory reporterFactory = createReporterFactory();
        HashMap<String, TestSet> classMethodCounts = new HashMap<String, TestSet>();
        final DefaultConsoleReporter defaultConsoleReporter = new DefaultConsoleReporter( System.out );
        RunListener reporter =
            new ClassesParallelRunListener( classMethodCounts, reporterFactory, defaultConsoleReporter );
        JUnitCoreRunListener runListener = new JUnitCoreRunListener( reporter, classMethodCounts );
View Full Code Here

    private RunStatistics runClasses( Class<?>... classes )
        throws TestSetFailedException
    {
        HashMap<String, TestSet> classMethodCounts = new HashMap<String, TestSet>();
        final ReporterFactory reporterManagerFactory = createReporterFactory();
        org.junit.runner.notification.RunListener demultiplexingRunListener =
            createRunListener( reporterManagerFactory, classMethodCounts );

        JUnitCore jUnitCore = new JUnitCore();

        jUnitCore.addListener( demultiplexingRunListener );
        Computer computer = new Computer();

        jUnitCore.run( computer, classes );
        reporterManagerFactory.close();
        return reporterManagerFactory.getGlobalRunStatistics();
    }
View Full Code Here

    }

    public RunResult invoke( Object forkTestSet )
        throws TestSetFailedException, ReporterException
    {
        final ReporterFactory reporterFactory = providerParameters.getReporterFactory();

        final ConsoleLogger consoleLogger = providerParameters.getConsoleLogger();

        Filter filter = jUnit48Reflector.isJUnit48Available() ? createJUnit48Filter() : null;

        if ( testsToRun == null )
        {
            if ( forkTestSet instanceof TestsToRun )
            {
                testsToRun = (TestsToRun) forkTestSet;
            }
            else if ( forkTestSet instanceof Class )
            {
                Class theClass = (Class) forkTestSet;
                testsToRun = TestsToRun.fromClass( theClass );
            }
            else
            {
                testsToRun = scanClassPath();
            }
        }

        org.junit.runner.notification.RunListener jUnit4RunListener = getRunListener( reporterFactory, consoleLogger );
        customRunListeners.add( 0, jUnit4RunListener );
        JUnitCoreWrapper.execute( testsToRun, jUnitCoreParameters, customRunListeners, filter );
        return reporterFactory.close();
    }
View Full Code Here

    @Test
    public void surefireIsConfused_ByMultipleIgnore_OnClassLevel()
        throws Exception
    {
        ReporterFactory reporterFactory = DefaultReporterFactory.defaultNoXml();
        BaseProviderFactory providerParameters = new BaseProviderFactory( reporterFactory, true );
        ConsoleLogger consoleLogger = new DefaultConsoleReporter( System.out );

        providerParameters.setReporterConfiguration( new ReporterConfiguration( new File( "" ), false ) );
        Properties junitProps = new Properties();
        junitProps.put( ProviderParameterNames.PARALLEL_PROP, "none" );

        JUnitCoreParameters jUnitCoreParameters = new JUnitCoreParameters( junitProps );

        final Map<String, TestSet> testSetMap = new ConcurrentHashMap<String, TestSet>();

        RunListener listener =
            ConcurrentRunListener.createInstance( testSetMap, reporterFactory, false, false, consoleLogger );

        TestsToRun testsToRun = new TestsToRun( Arrays.<Class>asList( TestClassTest.class ) );

        org.junit.runner.notification.RunListener jUnit4RunListener = new JUnitCoreRunListener( listener, testSetMap );

        List<org.junit.runner.notification.RunListener> customRunListeners =
            new ArrayList<org.junit.runner.notification.RunListener>();
        customRunListeners.add( 0, jUnit4RunListener );

        JUnitCoreWrapper.execute( testsToRun, jUnitCoreParameters, customRunListeners, null );

        RunResult result = reporterFactory.close();

        Assert.assertEquals( "JUnit should report correctly number of test ran(Finished)", 1,
                             result.getCompletedCount() );

    }
View Full Code Here

TOP

Related Classes of org.apache.maven.surefire.report.ReporterFactory

Copyright © 2018 www.massapicom. 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.