Package org.apache.maven.surefire.report

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


    @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 );

        try
        {
            // JUnitCoreWrapper#execute() is calling JUnit4RunListener#rethrowAnyTestMechanismFailures()
            // and rethrows a failure which happened in listener
            exception.expect( TestSetFailedException.class );
            JUnitCoreWrapper.execute( testsToRun, jUnitCoreParameters, customRunListeners, null );
        }
        finally
        {
            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 = DefaultReporterFactory.defaultNoXml();

        final HashMap<String, TestSet> classMethodCounts = new HashMap<String, TestSet>();
        RunListener reporter =
            ConcurrentRunListener.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

            {
                testsToRun = scanClassPath();
            }
        }

        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 ( Class clazz : testsToRun )
        {
            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 )
            {
                if ( forkTestSet instanceof TestsToRun )
                {
                    testsToRun = (TestsToRun) forkTestSet;
                }
                else if ( forkTestSet instanceof Class )
                {
                    testsToRun = TestsToRun.fromClass( (Class) forkTestSet );
                }
                else
                {
                    testsToRun = scanClassPath();
                }
            }
            TestNGDirectoryTestSuite suite = getDirectorySuite();
            suite.execute( testsToRun, reporterFactory );
        }

        return reporterFactory.close();
    }
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

    private static RunResult runSuitesInProcess( Object testSet, StartupConfiguration startupConfiguration,
                                                 ProviderConfiguration providerConfiguration,
                                                 PrintStream originalSystemOut )
        throws SurefireExecutionException, TestSetFailedException, InvocationTargetException
    {
        final ReporterFactory factory = createForkingReporterFactory( providerConfiguration, originalSystemOut );

        return invokeProviderInSameClassLoader( testSet, factory, providerConfiguration, true, startupConfiguration,
                                                false );
    }
View Full Code Here

            }
        }

        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 aTestsToRun : testsToRun )
        {
            executeTestSet( aTestsToRun, reporter, runNotifer );
        }

        runNotifer.fireTestRunFinished( result );

        JUnit4RunListener.rethrowAnyTestMechanismFailures( result );

        closeRunNotifer( jUnit4TestSetReporter, customRunListeners );

        return reporterFactory.close();
    }
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 );

        try
        {
            // JUnitCoreWrapper#execute() is calling JUnit4RunListener#rethrowAnyTestMechanismFailures()
            // and rethrows a failure which happened in listener
            exception.expect( TestSetFailedException.class );
            JUnitCoreWrapper.execute( testsToRun, jUnitCoreParameters, customRunListeners, null );
        }
        finally
        {
            RunResult result = reporterFactory.close();
            Assert.assertEquals( "JUnit should report correctly number of test ran(Finished)",
                    1, result.getCompletedCount() );
        }
    }
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 )
            {
                if ( forkTestSet instanceof TestsToRun )
                {
                    testsToRun = (TestsToRun) forkTestSet;
                }
                else if ( forkTestSet instanceof Class )
                {
                    testsToRun = TestsToRun.fromClass( (Class) forkTestSet );
                }
                else
                {
                    testsToRun = scanClassPath();
                }
            }
            TestNGDirectoryTestSuite suite = getDirectorySuite();
            suite.execute( testsToRun, reporterFactory );
        }

        return reporterFactory.close();
    }
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.