You are viewing a plain text version of this content. The canonical link for it is here.
Posted to surefire-commits@maven.apache.org by kr...@apache.org on 2010/06/23 21:40:01 UTC

svn commit: r957320 [2/2] - in /maven/surefire/trunk: surefire-api/src/main/java/org/apache/maven/surefire/ surefire-api/src/main/java/org/apache/maven/surefire/report/ surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ surefire-in...

Added: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java?rev=957320&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java (added)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java Wed Jun 23 19:39:59 2010
@@ -0,0 +1,201 @@
+package org.apache.maven.surefire.junitcore;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.surefire.Surefire;
+import org.apache.maven.surefire.report.ReportEntry;
+import org.apache.maven.surefire.report.ReporterManager;
+import org.junit.runner.Description;
+import org.junit.runner.notification.Failure;
+
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.ResourceBundle;
+
+/**
+ * Represents the test-state of a single test method that is run.
+ * <p/>
+ * Notes about thread safety: This instance is serially confined to 1-3 threads (construction, test-run, reporting),
+ * without any actual parallel access
+ */
+class TestMethod
+{
+    private final Description description;
+
+    private volatile Failure testFailure;
+
+    private volatile Failure testAssumptionFailure;
+
+    private volatile Description ignored;
+
+    private static final ResourceBundle bundle = ResourceBundle.getBundle( Surefire.SUREFIRE_BUNDLE_NAME );
+
+    private static final InheritableThreadLocal<TestMethod> testMethod = new InheritableThreadLocal<TestMethod>();
+
+    private volatile LogicalStream output;
+
+    public TestMethod( Description description )
+    {
+        this.description = description;
+    }
+
+
+    public void testFinished()
+        throws Exception
+    {
+    }
+
+
+    public void testIgnored( Description description )
+        throws Exception
+    {
+        ignored = description;
+
+    }
+
+    public void testFailure( Failure failure )
+        throws Exception
+    {
+        this.testFailure = failure;
+    }
+
+
+    public void testAssumptionFailure( Failure failure )
+    {
+        this.testAssumptionFailure = failure;
+    }
+
+    public void replay( ReporterManager reporter )
+        throws Exception
+    {
+
+        if ( ignored != null )
+        {
+            reporter.testSkipped( createReportEntry( "testSkipped" ) );
+            return;
+        }
+
+        reporter.testStarting( createReportEntry( "testStarting" ) );
+        if ( output != null )
+        {
+            // For some reason, console output is not written to the txt file.
+            output.writeToConsole( reporter );
+        }
+        if ( testFailure != null )
+        {
+            ReportEntry report = createFailureEntry( testFailure, "executeException" );
+            //noinspection ThrowableResultOfMethodCallIgnored
+            if ( testFailure.getException() instanceof AssertionError )
+            {
+                reporter.testFailed( report, getStdout(), getStdErr() );
+            }
+            else
+            {
+                reporter.testError( report, getStdout(), getStdErr() );
+            }
+
+        }
+        else if ( testAssumptionFailure != null )
+        {
+            // Does nothing...
+        }
+        else
+        {
+            reporter.testSucceeded( createReportEntry( "testSuccessful" ) );
+        }
+    }
+
+    private ReportEntry createReportEntry( String rawString2 )
+    {
+        String rawString = bundle.getString( rawString2 );
+        return new ReportEntry( description.getTestClass().getCanonicalName(), description.getDisplayName(),
+                                rawString );
+    }
+
+    private ReportEntry createFailureEntry( Failure failure, String rawString2 )
+    {
+        String rawString = bundle.getString( rawString2 );
+        return new ReportEntry( failure.getDescription().getTestClass().getCanonicalName(), failure.getTestHeader(),
+                                rawString, new JUnitCoreStackTraceWriter( failure ) );
+    }
+
+
+    public void attachToThread()
+    {
+        testMethod.set( this );
+    }
+
+    public static void detachFromCurrentThread()
+    {
+        testMethod.remove();
+    }
+
+    public static TestMethod getThreadTestMethod()
+    {
+        return testMethod.get();
+    }
+
+    public LogicalStream getLogicalStream()
+    {
+        if ( output == null )
+        {
+            output = new LogicalStream();
+        }
+        return output;
+    }
+
+
+    private String getStdout()
+    {
+        return output != null ? output.getOutput( true ) : "";
+    }
+
+    private String getStdErr()
+    {
+        return output != null ? output.getOutput( false ) : "";
+    }
+
+    public static void fillTestCountMap( Description description, Map<Class, TestSet> methodCount )
+    {
+        final ArrayList<Description> children = description.getChildren();
+
+        TestSet testSet = new TestSet( description );
+        Class<?> itemTestClass = null;
+        for ( Description item : children )
+        {
+            if ( item.isTest() )
+            {
+                testSet.incrementTestMethodCount();
+                if ( itemTestClass == null )
+                {
+                    itemTestClass = item.getTestClass();
+                }
+            }
+            else if ( item.getChildren().size() > 0 )
+            {
+                fillTestCountMap( item, methodCount );
+            }
+        }
+        if ( itemTestClass != null )
+        {
+            methodCount.put( itemTestClass, testSet );
+        }
+    }
+
+}

Propchange: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java?rev=957320&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java (added)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java Wed Jun 23 19:39:59 2010
@@ -0,0 +1,146 @@
+package org.apache.maven.surefire.junitcore;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.surefire.Surefire;
+import org.apache.maven.surefire.report.ReportEntry;
+import org.apache.maven.surefire.report.ReporterManager;
+import org.junit.runner.Description;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.ResourceBundle;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * * Represents the test-state of a testset that is run.
+ */
+public class TestSet
+{
+    private static ResourceBundle bundle = ResourceBundle.getBundle( Surefire.SUREFIRE_BUNDLE_NAME );
+
+    private final Description testSetDescription;
+
+    private AtomicInteger numberOfCompletedChildren = new AtomicInteger( 0 );
+
+    // While the two parameters below may seem duplicated, it is not entirely the case,
+    // since numberOfTests has the correct value from the start, while testMethods grows as method execution starts.
+
+    private final AtomicInteger numberOfTests = new AtomicInteger( 0 );
+
+    private final List<TestMethod> testMethods = Collections.synchronizedList( new ArrayList<TestMethod>() );
+
+    private static final InheritableThreadLocal<TestSet> testSet = new InheritableThreadLocal<TestSet>();
+
+    private AtomicBoolean allScheduled = new AtomicBoolean();
+    private AtomicBoolean played = new AtomicBoolean();
+
+
+    public TestSet( Description testSetDescription )
+    {
+        this.testSetDescription = testSetDescription;
+    }
+
+    public void replay( ReporterManager target )
+    {
+        if (!played.compareAndSet( false, true )) return;
+
+        try
+        {
+            ReportEntry report = createReportEntry( "testSetStarting" );
+
+            target.testSetStarting( report );
+
+            for ( TestMethod testMethod : testMethods )
+            {
+                testMethod.replay( target );
+            }
+            report = createReportEntry( "testSetCompletedNormally" );
+
+            target.testSetCompleted( report );
+
+            target.reset();
+        }
+        catch ( Exception e )
+        {
+            throw new RuntimeException( e );
+        }
+    }
+
+    public TestMethod createTestMethod( Description description )
+    {
+        TestMethod testMethod = new TestMethod( description );
+        addTestMethod( testMethod );
+        return testMethod;
+    }
+
+    private ReportEntry createReportEntry( String rawString2 )
+    {
+        String rawString = bundle.getString( rawString2 );
+        boolean isJunit3 = testSetDescription.getTestClass() == null;
+        String classNameToUse =
+            isJunit3 ? testSetDescription.getChildren().get( 0 ).getClassName() : testSetDescription.getClassName();
+        return new ReportEntry( classNameToUse, classNameToUse, rawString );
+    }
+
+    public void incrementTestMethodCount()
+    {
+        numberOfTests.incrementAndGet();
+    }
+
+    public void addTestMethod( TestMethod testMethod )
+    {
+        testMethods.add( testMethod );
+    }
+
+    public void incrementFinishedTests( ReporterManager reporterManager, boolean reportImmediately )
+    {
+        numberOfCompletedChildren.incrementAndGet();
+        if ( allScheduled.get() && isAllTestsDone() && reportImmediately)
+        {
+            replay( reporterManager );
+        }
+    }
+
+    public void setAllScheduled( ReporterManager reporterManager )
+    {
+        allScheduled.set( true );
+        if ( isAllTestsDone() )
+        {
+            replay( reporterManager );
+        }
+    }
+
+    private boolean isAllTestsDone()
+    {
+        return testMethods.size() == numberOfCompletedChildren.get();
+    }
+
+    public void attachToThread()
+    {
+        testSet.set( this );
+    }
+
+    public static TestSet getThreadTestSet()
+    {
+        return testSet.get();
+    }
+}

Propchange: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestsToRun.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestsToRun.java?rev=957320&r1=957319&r2=957320&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestsToRun.java (original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestsToRun.java Wed Jun 23 19:39:59 2010
@@ -44,9 +44,8 @@ class TestsToRun
         this.locatedClasses = locatedClasses;
         testSets = new HashMap<String, JUnitCoreTestSet>();
         int testCount = 0;
-        for ( int i = 0; i < locatedClasses.length; i++ )
+        for ( Class testClass : locatedClasses )
         {
-            Class testClass = locatedClasses[i];
             JUnitCoreTestSet testSet = new JUnitCoreTestSet( testClass );
 
             if ( testSets.containsKey( testSet.getName() ) )

Added: maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReportingRunListenerTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReportingRunListenerTest.java?rev=957320&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReportingRunListenerTest.java (added)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReportingRunListenerTest.java Wed Jun 23 19:39:59 2010
@@ -0,0 +1,412 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.maven.surefire.junitcore;
+
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.apache.maven.surefire.report.ReporterManagerFactory;
+import org.apache.maven.surefire.report.RunStatistics;
+import org.apache.maven.surefire.testset.TestSetFailedException;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.Computer;
+import org.junit.runner.JUnitCore;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import static junit.framework.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/*
+ * @author Kristian Rosenvold
+ */
+
+public class ConcurrentReportingRunListenerTest
+{
+    // Tests are in order of increasing complexity
+    @Test
+    public void testNoErrorsCounting() throws Exception
+    {
+        runClasses(  3, 0 ,0, DummyAllOk.class );
+    }
+
+    @Test
+    public void testNoErrorsCounting2() throws Exception
+    {
+        runClasses( 2, 0 ,0 , Dummy3.class );
+    }
+
+    @Test
+    public void testOneIgnoreCounting() throws Exception
+    {
+        runClasses( 3, 1, 0, DummyWithOneIgnore.class  );
+    }
+
+    @Test
+    public void testOneFailureCounting() throws Exception
+    {
+        runClasses( 3, 0 ,1,  DummyWithFailure.class  );
+    }
+
+    @Test
+    public void testWithErrorsCountingDemultiplexed()
+        throws Exception
+    {
+        runClasses( 6, 1, 1 , DummyWithOneIgnore.class, DummyWithFailure.class);
+    }
+
+
+    @Test
+    public void testJunitResultCountingDemultiplexed()
+        throws Exception
+    {
+        runClasses( 8, 1, 1, DummyWithOneIgnore.class, DummyWithFailure.class, Dummy3.class   );
+    }
+
+    @Test
+    public void testJunitResultCountingJUnit3Demultiplexed()
+        throws Exception
+    {
+        runClasses( 3, 0 ,0, Junit3Tc1.class, Junit3Tc2.class  );
+    }
+
+    @Test
+    public void testJunitResultCountingJUnit3OddTest()
+        throws Exception
+    {
+        runClasses( 2, 0 ,0, Junit3OddTest1.class );
+    }
+
+    @Test
+    public void testJunit3WithNestedSuite()
+        throws TestSetFailedException
+    {
+        runClasses(  4, 0 ,0, Junit3WithNestedSuite.class );
+    }
+
+    @Test
+    public void testJunit3NestedSuite()
+        throws Exception
+    {
+        runClasses( 2, 0 ,0, Junit3OddTest1.class );
+    }
+
+
+    @Test
+    public void testSimpleOutput()
+        throws Exception
+    {
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        PrintStream collector = new PrintStream( byteArrayOutputStream );
+        PrintStream orgOur = System.out;
+        System.setOut( collector );
+
+        RunStatistics result = runClasses(Dummy3.class);
+        assertReporter( result,  2, 0 ,0, "msgs" );
+
+
+        String foo = new String( byteArrayOutputStream.toByteArray() );
+        assertNotNull( foo );
+
+        System.setOut( orgOur );
+    }
+
+    @Test
+    public void testOutputOrdering()
+        throws Exception
+    {
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        PrintStream collector = new PrintStream( byteArrayOutputStream );
+        PrintStream orgOur = System.out;
+        System.setOut( collector );
+
+        RunStatistics result = runClasses(DummyWithOneIgnore.class, DummyWithFailure.class, Dummy3.class);
+        assertReporter( result,  8, 1 ,1, "msgs" );
+
+
+        String foo = new String( byteArrayOutputStream.toByteArray() );
+        assertNotNull( foo );
+
+        System.setOut( orgOur );
+
+//        final List<String> stringList = result.getEvents();
+//        assertEquals( 23, stringList.size() );
+    }
+
+    private void runClasses( int success, int ignored, int failure, Class... classes )
+        throws TestSetFailedException
+    {
+        ReporterManagerFactory reporterManagerFactory = createReporterFactory();
+        RunStatistics result = runClasses(reporterManagerFactory, new ConcurrentReportingRunListener.ClassesParallelRunListener( reporterManagerFactory ),  classes);
+        assertReporter(  result, success, ignored ,failure, "classes" );
+
+        reporterManagerFactory = createReporterFactory();
+        result = runClasses(reporterManagerFactory, new ConcurrentReportingRunListener.MethodsParallelRunListener(reporterManagerFactory, true) , classes);
+        assertReporter(  result, success, ignored ,failure, "methods" );
+
+        reporterManagerFactory = createReporterFactory();
+        result = runClasses(reporterManagerFactory, new ConcurrentReportingRunListener.MethodsParallelRunListener(reporterManagerFactory, false) , classes);
+        assertReporter(  result, success, ignored ,failure, "methods" );
+
+    }
+
+    private RunStatistics runClasses( Class... classes )
+        throws TestSetFailedException
+    {
+        final ReporterManagerFactory reporterManagerFactory = createReporterFactory();
+        ConcurrentReportingRunListener demultiplexingRunListener = createRunListener( reporterManagerFactory );
+
+        JUnitCore jUnitCore = new JUnitCore();
+
+        jUnitCore.addListener( demultiplexingRunListener );
+        Computer computer = new Computer();
+
+        jUnitCore.run( computer, classes );
+        return reporterManagerFactory.getGlobalRunStatistics();
+    }
+
+    private RunStatistics runClasses( ReporterManagerFactory reporterManagerFactory, ConcurrentReportingRunListener demultiplexingRunListener, Class... classes )
+        throws TestSetFailedException
+    {
+
+        JUnitCore jUnitCore = new JUnitCore();
+
+        jUnitCore.addListener( demultiplexingRunListener );
+        Computer computer = new Computer();
+
+        jUnitCore.run( computer, classes );
+        return reporterManagerFactory.getGlobalRunStatistics();
+    }
+
+    private ConcurrentReportingRunListener createRunListener( ReporterManagerFactory reporterFactory )
+        throws TestSetFailedException
+    {
+        return new ConcurrentReportingRunListener.ClassesParallelRunListener( reporterFactory );
+    }
+
+
+    public static class DummyWithOneIgnore
+    {
+        @Test
+        public void testNotMuch()
+        {
+
+        }
+
+        @Ignore
+        @Test
+        public void testStub1()
+        {
+        }
+
+        @Test
+        public void testStub2()
+        {
+        }
+    }
+
+    public static class DummyWithFailure
+    {
+
+        @Test
+        public void testBeforeFail()
+        {
+
+        }
+
+        @Test
+        public void testWillFail()
+        {
+            Assert.fail( "We will fail" );
+        }
+
+        @Test
+        public void testAfterFail()
+        {
+        }
+    }
+
+    public static class DummyAllOk
+    {
+
+        @Test
+        public void testNotMuchA()
+        {
+
+        }
+
+        @Test
+        public void testStub1A()
+        {
+        }
+
+        @Test
+        public void testStub2A()
+        {
+        }
+    }
+
+    public static class Dummy3
+    {
+
+        @Test
+        public void testNotMuchA()
+        {
+            System.out.println( "tNMA1" );
+            System.err.println( "tNMA1err" );
+        }
+
+        @Test
+        public void testStub2A()
+        {
+            System.out.println( "tS2A" );
+            System.err.println( "tS2AErr" );
+        }
+    }
+
+    public static class Junit3Tc1
+        extends TestCase
+    {
+
+        public Junit3Tc1()
+        {
+            super( "testNotMuchJunit3TC1" );
+        }
+
+        public void testNotMuchJunit3TC1()
+        {
+            System.out.println( "Junit3TC1" );
+        }
+
+
+        public static junit.framework.Test suite()
+        {
+            TestSuite suite = new TestSuite();
+            suite.addTest( new Junit3Tc1() );
+            return suite;
+        }
+    }
+
+    public static class Junit3Tc2
+        extends TestCase
+    {
+        public Junit3Tc2( String testMethod )
+        {
+            super( testMethod );
+        }
+
+        public void testNotMuchJunit3TC2()
+        {
+            System.out.println( "Junit3TC2" );
+        }
+
+        public void testStubJ3TC2A()
+        {
+            System.out.println( "testStubJ3TC2A" );
+        }
+
+
+        public static junit.framework.Test suite()
+        {
+            TestSuite suite = new TestSuite();
+            suite.addTest( new Junit3Tc2( "testNotMuchJunit3TC2" ) );
+            suite.addTest( new Junit3Tc2( "testStubJ3TC2A" ) );
+            return suite;
+        }
+    }
+
+    public static class Junit3OddTest1
+        extends TestCase
+    {
+
+
+        public static junit.framework.Test suite()
+        {
+            TestSuite suite = new TestSuite();
+
+            suite.addTest( new Junit3OddTest1( "testMe" ) );
+            suite.addTest( new Junit3OddTest1( "testMe" ) );
+
+
+
+            return suite;
+        }
+
+
+        public Junit3OddTest1( String name )
+        {
+            super( name );
+        }
+
+        public void testMe()
+        {
+            assertTrue( true );
+        }
+    }
+
+    public static class Junit3WithNestedSuite
+        extends TestCase
+    {
+
+
+        public static junit.framework.Test suite()
+        {
+            TestSuite suite = new TestSuite();
+
+            suite.addTest( new Junit3WithNestedSuite( "testMe2" ) );
+            suite.addTest( new Junit3WithNestedSuite( "testMe2" ) );
+            suite.addTestSuite(   Junit3Tc2.class);
+            return suite;
+        }
+
+
+        public Junit3WithNestedSuite( String name )
+        {
+            super( name );
+        }
+
+        public void testMe2()
+        {
+            assertTrue( true );
+        }
+    }
+
+
+    private ReporterManagerFactory createReporterFactory()
+    {
+        Object[] reporter = new Object[]{MockReporter.class.getCanonicalName(), new Object[] {} };
+        final List<Object> objects = new ArrayList();
+        objects.add( reporter );
+        return new ReporterManagerFactory(objects, this.getClass().getClassLoader());
+    }
+
+    private void assertReporter( RunStatistics result, int success, int ignored, int failure, String message )
+    {
+        assertEquals( message,  success, result.getCompletedCount() );
+        assertEquals( message,  failure, result.getFailureSources().size() );
+        assertEquals( message,  ignored, result.getSkipped() );
+    }
+
+}

Propchange: maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReportingRunListenerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MockReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MockReporter.java?rev=957320&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MockReporter.java (added)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MockReporter.java Wed Jun 23 19:39:59 2010
@@ -0,0 +1,114 @@
+package org.apache.maven.surefire.junitcore;
+
+import org.apache.maven.surefire.report.ReportEntry;
+import org.apache.maven.surefire.report.Reporter;
+import org.apache.maven.surefire.report.ReporterException;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class MockReporter implements Reporter
+{
+    private final List<String> events = new ArrayList<String>( );
+    public static final String RUN_STARTED = "RUN_STARTED";
+    public static final String RUN_COMPLETED = "RUN_COMPLETED";
+    public static final String SET_STARTED = "SET_STARTED";
+    public static final String SET_COMPLETED = "SET_COMPLETED";
+    public static final String TEST_STARTED = "TEST_STARTED";
+    public static final String TEST_COMPLETED = "TEST_COMPLETED";
+    public static final String TEST_FAILED= "TEST_FAILED";
+    public static final String TEST_ERROR = "TEST_ERROR";
+    public static final String TEST_SKIPPED = "TEST_SKIPPED";
+
+    private final AtomicInteger testSucceeded = new AtomicInteger( );
+    private final AtomicInteger testIgnored = new AtomicInteger( );
+    private final AtomicInteger testFailed = new AtomicInteger( );
+    private final AtomicInteger testError = new AtomicInteger( );
+
+
+    public void runStarting( )
+    {
+        events.add(RUN_STARTED);
+    }
+
+    public void runCompleted()
+    {
+        events.add( RUN_COMPLETED);
+    }
+
+    public void testSetStarting( ReportEntry report )
+        throws ReporterException
+    {
+        events.add( SET_STARTED);
+    }
+
+    public void testSetCompleted( ReportEntry report )
+        throws ReporterException
+    {
+        events.add( SET_COMPLETED);
+    }
+
+    public void testStarting( ReportEntry report )
+    {
+        events.add( TEST_STARTED);
+    }
+
+    public void testSucceeded( ReportEntry report )
+    {
+        events.add( TEST_COMPLETED);
+        testSucceeded.incrementAndGet();
+
+    }
+
+    public void testError( ReportEntry report, String stdOut, String stdErr )
+    {
+        events.add( TEST_ERROR);
+        testError.incrementAndGet();
+    }
+
+    public void testFailed( ReportEntry report, String stdOut, String stdErr )
+    {
+        events.add( TEST_FAILED);
+        testFailed.incrementAndGet();
+    }
+
+    public void testSkipped( ReportEntry report )
+    {
+        events.add( TEST_SKIPPED);
+        testIgnored.incrementAndGet();
+    }
+
+    public void reset()
+    {
+    }
+
+    public void writeMessage( String message )
+    {
+    }
+
+    public void writeFooter( String footer )
+    {
+    }
+
+    public List<String> getEvents()
+    {
+        return events;
+    }
+
+    public int getTestSucceeded()
+    {
+        return testSucceeded.get();
+    }
+
+    public int getTestIgnored()
+    {
+        return testIgnored.get();
+    }
+
+    public int getTestFailed()
+    {
+        return testFailed.get();
+    }
+
+}

Propchange: maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MockReporter.java
------------------------------------------------------------------------------
    svn:eol-style = native