You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kr...@apache.org on 2012/08/15 20:45:41 UTC

svn commit: r1373562 - in /maven/surefire/trunk: maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ maven-surefire-common/src/main/java/org/apache/maven/plu...

Author: krosenvold
Date: Wed Aug 15 18:45:29 2012
New Revision: 1373562

URL: http://svn.apache.org/viewvc?rev=1373562&view=rev
Log:
o Simplified reporters.

Got rid of most of the mutable state in the reporters. There is still some conceptual duplication
going on in TestSetRunListener, and the Reporter classes have a somewhat overkill class
hierarchy. But this should be much easier to clean up now.

Added:
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetStats.java
    maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/
    maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/XMLReporterTest.java
      - copied, changed from r1372903, maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java
Removed:
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/AbstractReporter.java
    maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/DescriptionDecoder.java
    maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/DescriptionDecoderTest.java
Modified:
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/StartupReportConfiguration.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/AbstractConsoleReporter.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/AbstractFileReporter.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/AbstractTextReporter.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/BriefConsoleReporter.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/BriefFileReporter.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleReporter.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactory.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DetailedConsoleReporter.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporter.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/MulticastingReporter.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/Reporter.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/XMLReporter.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java
    maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/StartupReportConfiguration.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/StartupReportConfiguration.java?rev=1373562&r1=1373561&r2=1373562&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/StartupReportConfiguration.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/StartupReportConfiguration.java Wed Aug 15 18:45:29 2012
@@ -137,7 +137,7 @@ public class StartupReportConfiguration
     {
         if ( !isDisableXmlReport() )
         {
-            return new XMLReporter( trimStackTrace, reportsDirectory, reportNameSuffix );
+            return new XMLReporter( reportsDirectory, reportNameSuffix );
         }
         return null;
     }
@@ -148,11 +148,11 @@ public class StartupReportConfiguration
         {
             if ( BRIEF_REPORT_FORMAT.equals( getReportFormat() ) )
             {
-                return new BriefFileReporter( trimStackTrace, reportsDirectory, getReportNameSuffix() );
+                return new BriefFileReporter( reportsDirectory, getReportNameSuffix() );
             }
             else if ( PLAIN_REPORT_FORMAT.equals( getReportFormat() ) )
             {
-                return new FileReporter( trimStackTrace, reportsDirectory, getReportNameSuffix() );
+                return new FileReporter( reportsDirectory, getReportNameSuffix() );
             }
         }
         return null;
@@ -163,15 +163,15 @@ public class StartupReportConfiguration
     {
         if ( isUseFile() )
         {
-            return isPrintSummary() ? new ConsoleReporter( trimStackTrace ) : null;
+            return isPrintSummary() ? new ConsoleReporter() : null;
         }
         else if ( isRedirectTestOutputToFile() || BRIEF_REPORT_FORMAT.equals( getReportFormat() ) )
         {
-            return new BriefConsoleReporter( trimStackTrace );
+            return new BriefConsoleReporter();
         }
         else if ( PLAIN_REPORT_FORMAT.equals( getReportFormat() ) )
         {
-            return new DetailedConsoleReporter( trimStackTrace );
+            return new DetailedConsoleReporter();
         }
         return null;
     }

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/AbstractConsoleReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/AbstractConsoleReporter.java?rev=1373562&r1=1373561&r2=1373562&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/AbstractConsoleReporter.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/AbstractConsoleReporter.java Wed Aug 15 18:45:29 2012
@@ -44,9 +44,9 @@ public abstract class AbstractConsoleRep
 
     private static final PrintStream ORIGINAL_SYSTEM_OUT = System.out;
 
-    AbstractConsoleReporter( boolean trimStackTrace, String format )
+    AbstractConsoleReporter( String format )
     {
-        super( getPrintWriter(), trimStackTrace, format );
+        super( getPrintWriter(), format );
     }
 
     private static PrintWriter getPrintWriter()

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/AbstractFileReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/AbstractFileReporter.java?rev=1373562&r1=1373561&r2=1373562&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/AbstractFileReporter.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/AbstractFileReporter.java Wed Aug 15 18:45:29 2012
@@ -40,14 +40,14 @@ public abstract class AbstractFileReport
 
     private final String reportNameSuffix;
 
-    AbstractFileReporter( boolean trimStackTrace, String format, File reportsDirectory )
+    AbstractFileReporter( String format, File reportsDirectory )
     {
-        this( trimStackTrace, format, reportsDirectory, null );
+        this( format, reportsDirectory, null );
     }
 
-    AbstractFileReporter( boolean trimStackTrace, String format, File reportsDirectory, String reportNameSuffix )
+    AbstractFileReporter( String format, File reportsDirectory, String reportNameSuffix )
     {
-        super( trimStackTrace, format );
+        super( format );
         this.reportsDirectory = reportsDirectory;
         this.deleteOnStarting = false;
         this.reportNameSuffix = reportNameSuffix;
@@ -105,10 +105,10 @@ public abstract class AbstractFileReport
         return reportFile;
     }
 
-    public void testSetCompleted( ReportEntry report )
+    public void testSetCompleted( ReportEntry report, TestSetStats testSetStats )
         throws ReporterException
     {
-        super.testSetCompleted( report );
+        super.testSetCompleted( report, testSetStats );
 
         writer.flush();
 

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/AbstractTextReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/AbstractTextReporter.java?rev=1373562&r1=1373561&r2=1373562&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/AbstractTextReporter.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/AbstractTextReporter.java Wed Aug 15 18:45:29 2012
@@ -31,7 +31,7 @@ import org.apache.maven.surefire.report.
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
  */
 public abstract class AbstractTextReporter
-    extends AbstractReporter
+    implements Reporter
 {
     static final String BRIEF = "brief";
 
@@ -39,24 +39,24 @@ public abstract class AbstractTextReport
 
     static final String SUMMARY = "summary";
 
-    protected PrintWriter writer;
+    private final boolean isPlain;
 
-    private static final String TEST_SET_COMPLETED_PREFIX = "Tests run: ";
+    private final boolean isBrief;
 
-    private final String format;
+    protected PrintWriter writer;
 
     private List<String> testResults;
 
 
-    protected AbstractTextReporter( boolean trimStackTrace, String format )
+    protected AbstractTextReporter( String format )
     {
-        super( trimStackTrace );
-        this.format = format;
+        isPlain = PLAIN.equals( format );
+        isBrief = BRIEF.equals( format );
     }
 
-    protected AbstractTextReporter( PrintWriter writer, boolean trimStackTrace, String format )
+    protected AbstractTextReporter( PrintWriter writer, String format )
     {
-        this( trimStackTrace, format );
+        this( format );
         this.writer = writer;
     }
 
@@ -76,56 +76,44 @@ public abstract class AbstractTextReport
         }
     }
 
-    public void testSucceeded( ReportEntry report )
+    public void testSucceeded( ReportEntry report, TestSetStats testSetStats )
     {
-        super.testSucceeded( report );
-
-        if ( PLAIN.equals( format ) )
+        if ( isPlain )
         {
-            testResults.add( getElapsedTimeSummary( report ) );
+            testResults.add( testSetStats.getElapsedTimeSummary( report ) );
         }
     }
 
-    public void testSkipped( ReportEntry report )
+    public void testSkipped( ReportEntry report, TestSetStats testSetStats )
     {
-        super.testSkipped( report );
-
-        if ( PLAIN.equals( format ) )
+        if ( isPlain )
         {
             testResults.add( report.getName() + " skipped" );
         }
     }
 
-    public void testError( ReportEntry report, String stdOut, String stdErr )
+    public void testError( ReportEntry report, String stdOut, String stdErr, TestSetStats testSetStats )
     {
-        super.testError( report, stdOut, stdErr );
-
-        testResults.add( getOutput( report, "ERROR" ) );
+        testResults.add( testSetStats.getOutput( report, "ERROR" ) );
     }
 
-    public void testFailed( ReportEntry report, String stdOut, String stdErr )
+    public void testFailed( ReportEntry report, String stdOut, String stdErr, TestSetStats testSetStats )
     {
-        super.testFailed( report, stdOut, stdErr );
-
-        testResults.add( getOutput( report, "FAILURE" ) );
+        testResults.add( testSetStats.getOutput( report, "FAILURE" ) );
     }
 
     public void testSetStarting( ReportEntry report )
         throws ReporterException
     {
-        super.testSetStarting( report );
-
         testResults = new ArrayList<String>();
     }
 
-    public void testSetCompleted( ReportEntry report )
+    public void testSetCompleted( ReportEntry report, TestSetStats testSetStats )
         throws ReporterException
     {
-        super.testSetCompleted( report );
+        writeMessage( testSetStats.getTestSetSummary( report.getElapsed() ) );
 
-        writeMessage( getTestSetSummary( report ) );
-
-        if ( format.equals( BRIEF ) || format.equals( PLAIN ) )
+        if ( isBrief || isPlain )
         {
             for ( String testResult : testResults )
             {
@@ -134,63 +122,13 @@ public abstract class AbstractTextReport
         }
     }
 
-    protected String getTestSetSummary( ReportEntry report )
+    public void testStarting( ReportEntry report )
     {
-        StringBuilder buf = new StringBuilder();
-
-        buf.append( TEST_SET_COMPLETED_PREFIX );
-        buf.append( completedCount );
-        buf.append( ", Failures: " );
-        buf.append( failures );
-        buf.append( ", Errors: " );
-        buf.append( errors );
-        buf.append( ", Skipped: " );
-        buf.append( skipped );
-        buf.append( ", Time elapsed: " );
-        int elapsed =
-            report.getElapsed() != null ? report.getElapsed() : (int) ( System.currentTimeMillis() - testSetStartTime );
-        buf.append( elapsedTimeAsString( elapsed ) );
-        buf.append( " sec" );
-
-        if ( failures > 0 || errors > 0 )
-        {
-            buf.append( " <<< FAILURE!" );
-        }
-
-        buf.append( "\n" );
-
-        return buf.toString();
-    }
-
-    protected String getElapsedTimeSummary( ReportEntry report )
-    {
-        StringBuilder reportContent = new StringBuilder();
-        long runTime = getActualRunTime( report );
-
-        reportContent.append( report.getName() );
-        reportContent.append( "  Time elapsed: " );
-        reportContent.append( elapsedTimeAsString( runTime ) );
-        reportContent.append( " sec" );
-
-        return reportContent.toString();
     }
 
-    protected String getOutput( ReportEntry report, String msg )
-    {
-        StringBuilder buf = new StringBuilder();
-
-        buf.append( getElapsedTimeSummary( report ) );
-
-        buf.append( "  <<< " ).append( msg ).append( "!" ).append( NL );
-
-        buf.append( getStackTrace( report ) );
-
-        return buf.toString();
-    }
 
     public void reset()
     {
-        super.reset();
         if ( writer != null )
         {
             writer.flush();

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/BriefConsoleReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/BriefConsoleReporter.java?rev=1373562&r1=1373561&r2=1373562&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/BriefConsoleReporter.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/BriefConsoleReporter.java Wed Aug 15 18:45:29 2012
@@ -30,8 +30,8 @@ public class BriefConsoleReporter
     extends AbstractConsoleReporter
 {
 
-    public BriefConsoleReporter( boolean trimStackTrace )
+    public BriefConsoleReporter()
     {
-        super( trimStackTrace, BRIEF );
+        super( BRIEF );
     }
 }

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/BriefFileReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/BriefFileReporter.java?rev=1373562&r1=1373561&r2=1373562&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/BriefFileReporter.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/BriefFileReporter.java Wed Aug 15 18:45:29 2012
@@ -31,8 +31,8 @@ public class BriefFileReporter
     extends AbstractFileReporter
 {
 
-    public BriefFileReporter( boolean trimStackTrace, File reportsDirectory, String reportNameSuffix )
+    public BriefFileReporter( File reportsDirectory, String reportNameSuffix )
     {
-        super( trimStackTrace, BRIEF, reportsDirectory, reportNameSuffix );
+        super( BRIEF, reportsDirectory, reportNameSuffix );
     }
 }

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleReporter.java?rev=1373562&r1=1373561&r2=1373562&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleReporter.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleReporter.java Wed Aug 15 18:45:29 2012
@@ -29,8 +29,8 @@ public class ConsoleReporter
     extends AbstractConsoleReporter
 {
 
-    public ConsoleReporter( boolean trimStackTrace )
+    public ConsoleReporter()
     {
-        super( trimStackTrace, SUMMARY );
+        super(SUMMARY );
     }
 }

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactory.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactory.java?rev=1373562&r1=1373561&r2=1373562&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactory.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactory.java Wed Aug 15 18:45:29 2012
@@ -19,12 +19,10 @@ package org.apache.maven.plugin.surefire
  * under the License.
  */
 
-import java.io.PrintStream;
 import java.util.ArrayList;
 import java.util.List;
 import org.apache.maven.plugin.surefire.StartupReportConfiguration;
 import org.apache.maven.plugin.surefire.runorder.StatisticsReporter;
-import org.apache.maven.surefire.report.ConsoleLogger;
 import org.apache.maven.surefire.report.DefaultDirectConsoleReporter;
 import org.apache.maven.surefire.report.ReporterConfiguration;
 import org.apache.maven.surefire.report.ReporterFactory;
@@ -70,13 +68,11 @@ public class DefaultReporterFactory
 
     public RunListener createReporter()
     {
-        final PrintStream sout = reportConfiguration.getOriginalSystemOut();
-        final PrintStream serr = reportConfiguration.getOriginalSystemErr();
         return new TestSetRunListener( reportConfiguration.instantiateConsoleReporter(),
                                        reportConfiguration.instantiateFileReporter(),
                                        reportConfiguration.instantiateXmlReporter(),
                                        reportConfiguration.instantiateConsoleOutputFileReporter(),
-                                       statisticsReporter, globalStats );
+                                       statisticsReporter, globalStats, reportConfiguration.isTrimStackTrace() );
     }
 
     private List<Reporter> instantiateReports()

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DetailedConsoleReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DetailedConsoleReporter.java?rev=1373562&r1=1373561&r2=1373562&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DetailedConsoleReporter.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DetailedConsoleReporter.java Wed Aug 15 18:45:29 2012
@@ -29,8 +29,8 @@ public class DetailedConsoleReporter
     extends AbstractConsoleReporter
 {
 
-    public DetailedConsoleReporter( boolean trimStackTrace )
+    public DetailedConsoleReporter()
     {
-        super( trimStackTrace, PLAIN );
+        super(PLAIN );
     }
 }

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporter.java?rev=1373562&r1=1373561&r2=1373562&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporter.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporter.java Wed Aug 15 18:45:29 2012
@@ -31,8 +31,8 @@ public class FileReporter
     extends AbstractFileReporter
 {
 
-    public FileReporter( boolean trimStackTrace, File reportsDirectory, String reportNamePrefix )
+    public FileReporter( File reportsDirectory, String reportNamePrefix )
     {
-        super( trimStackTrace, PLAIN, reportsDirectory, reportNamePrefix );
+        super(PLAIN, reportsDirectory, reportNamePrefix );
     }
 }

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/MulticastingReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/MulticastingReporter.java?rev=1373562&r1=1373561&r2=1373562&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/MulticastingReporter.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/MulticastingReporter.java Wed Aug 15 18:45:29 2012
@@ -52,11 +52,11 @@ public class MulticastingReporter
         }
     }
 
-    public void testSetCompleted( ReportEntry report )
+    public void testSetCompleted(ReportEntry report, TestSetStats testSetStats)
     {
         for ( int i = 0; i < size; i++ )
         {
-            target[i].testSetCompleted( report );
+            target[i].testSetCompleted( report, testSetStats);
         }
     }
 
@@ -70,39 +70,39 @@ public class MulticastingReporter
         }
     }
 
-    public void testSucceeded( ReportEntry report )
+    public void testSucceeded(ReportEntry report, TestSetStats testSetStats)
     {
         ReportEntry wrapped = wrap( report );
         for ( int i = 0; i < size; i++ )
         {
-            target[i].testSucceeded( wrapped );
+            target[i].testSucceeded( wrapped, testSetStats);
         }
     }
 
-    public void testError( ReportEntry report, String stdOut, String stdErr )
+    public void testError(ReportEntry report, String stdOut, String stdErr, TestSetStats testSetStats)
     {
         ReportEntry wrapped = wrap( report );
         for ( int i = 0; i < size; i++ )
         {
-            target[i].testError( wrapped, stdOut, stdErr );
+            target[i].testError( wrapped, stdOut, stdErr, testSetStats);
         }
     }
 
-    public void testFailed( ReportEntry report, String stdOut, String stdErr )
+    public void testFailed(ReportEntry report, String stdOut, String stdErr, TestSetStats testSetStats)
     {
         ReportEntry wrapped = wrap( report );
         for ( int i = 0; i < size; i++ )
         {
-            target[i].testFailed( wrapped, stdOut, stdErr );
+            target[i].testFailed( wrapped, stdOut, stdErr, testSetStats);
         }
     }
 
-    public void testSkipped( ReportEntry report )
+    public void testSkipped(ReportEntry report, TestSetStats testSetStats)
     {
         ReportEntry wrapped = wrap( report );
         for ( int i = 0; i < size; i++ )
         {
-            target[i].testSkipped( wrapped );
+            target[i].testSkipped( wrapped, testSetStats);
         }
     }
 

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/Reporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/Reporter.java?rev=1373562&r1=1373561&r2=1373562&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/Reporter.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/Reporter.java Wed Aug 15 18:45:29 2012
@@ -47,7 +47,7 @@ public interface Reporter
      * @throws org.apache.maven.surefire.report.ReporterException
      *          When reporting fails
      */
-    void testSetCompleted( ReportEntry report )
+    void testSetCompleted( ReportEntry report, TestSetStats testSetStats )
         throws ReporterException;
 
     // Tests
@@ -64,10 +64,10 @@ public interface Reporter
      *
      * @param report The report entry to log for
      */
-    void testSucceeded( ReportEntry report );
+    void testSucceeded( ReportEntry report, TestSetStats testSetStats );
 
 
-    void testSkipped( ReportEntry report );
+    void testSkipped( ReportEntry report, TestSetStats testSetStats );
 
     /**
      * Event fired when a test ended with an error (non anticipated problem)
@@ -76,7 +76,7 @@ public interface Reporter
      * @param stdOut standard output from the test case
      * @param stdErr error output from the test case
      */
-    void testError( ReportEntry report, String stdOut, String stdErr );
+    void testError( ReportEntry report, String stdOut, String stdErr, TestSetStats testSetStats );
 
     /**
      * Event fired when a test ended with a failure (anticipated problem)
@@ -85,7 +85,7 @@ public interface Reporter
      * @param stdOut standard output from the test case
      * @param stdErr error output from the test case
      */
-    void testFailed( ReportEntry report, String stdOut, String stdErr );
+    void testFailed( ReportEntry report, String stdOut, String stdErr, TestSetStats testSetStats );
 
     /**
      * Writes a message that will be displayed in all free-text format reporters.

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java?rev=1373562&r1=1373561&r2=1373562&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java Wed Aug 15 18:45:29 2012
@@ -1,180 +1,196 @@
-package org.apache.maven.plugin.surefire.report;
-
-/*
- * 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 java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import org.apache.maven.plugin.surefire.runorder.StatisticsReporter;
-import org.apache.maven.surefire.report.*;
-import org.apache.maven.surefire.util.internal.ByteBuffer;
-
-/**
- * Reports data for a single test set.
- * <p/>
- */
-public class TestSetRunListener
-    implements RunListener, ConsoleOutputReceiver, ConsoleLogger
-{
-    private final TestSetStatistics testSetStatistics;
-
-    private final RunStatistics globalStatistics;
-
-    private final MulticastingReporter multicastingReporter;
-
-    private final List<ByteBuffer> testStdOut = Collections.synchronizedList( new ArrayList<ByteBuffer>() );
-
-    private final List<ByteBuffer> testStdErr = Collections.synchronizedList( new ArrayList<ByteBuffer>() );
-
-    private final TestcycleConsoleOutputReceiver consoleOutputReceiver;
-
-    public TestSetRunListener( AbstractConsoleReporter consoleReporter, AbstractFileReporter fileReporter,
-                               XMLReporter xmlReporter, TestcycleConsoleOutputReceiver consoleOutputReceiver, StatisticsReporter statisticsReporter,
-                               RunStatistics globalStats )
-    {
-        List<Reporter> reporters = new ArrayList<Reporter>();
-        if ( consoleReporter != null )
-        {
-            reporters.add( consoleReporter );
-        }
-        if ( fileReporter != null )
-        {
-            reporters.add( fileReporter );
-        }
-        if ( xmlReporter != null )
-        {
-            reporters.add( xmlReporter );
-        }
-        if ( statisticsReporter != null )
-        {
-            reporters.add( statisticsReporter );
-        }
-
-        this.consoleOutputReceiver = consoleOutputReceiver;
-
-        multicastingReporter = new MulticastingReporter( reporters );
-        this.testSetStatistics = new TestSetStatistics();
-        this.globalStatistics = globalStats;
-    }
-
-    public void info( String message )
-    {
-        multicastingReporter.writeMessage( message );
-    }
-
-    public void writeTestOutput( byte[] buf, int off, int len, boolean stdout )
-    {
-        ByteBuffer byteBuffer = new ByteBuffer( buf, off, len );
-        if ( stdout )
-        {
-            testStdOut.add( byteBuffer );
-        }
-        else
-        {
-            testStdErr.add( byteBuffer );
-        }
-        consoleOutputReceiver.writeTestOutput( buf, off, len, stdout );
-    }
-
-    public void testSetStarting( ReportEntry report )
-    {
-        multicastingReporter.testSetStarting(report);
-        consoleOutputReceiver.testSetStarting( report);
-    }
-
-    public void clearCapture()
-    {
-        testStdErr.clear();
-        testStdOut.clear();
-    }
-
-    public void testSetCompleted( ReportEntry report )
-    {
-        multicastingReporter.testSetCompleted( report );
-        consoleOutputReceiver.testSetCompleted( report);
-        multicastingReporter.reset();
-        globalStatistics.add(testSetStatistics);
-        testSetStatistics.reset();
-    }
-
-    // ----------------------------------------------------------------------
-    // Test
-    // ----------------------------------------------------------------------
-
-    public void testStarting( ReportEntry report )
-    {
-        multicastingReporter.testStarting( report );
-    }
-
-    public void testSucceeded( ReportEntry report )
-    {
-        testSetStatistics.incrementCompletedCount();
-        multicastingReporter.testSucceeded( report );
-        clearCapture();
-    }
-
-    public void testError( ReportEntry reportEntry )
-    {
-        multicastingReporter.testError( reportEntry, getAsString( testStdOut ), getAsString( testStdErr ) );
-        testSetStatistics.incrementErrorsCount();
-        testSetStatistics.incrementCompletedCount();
-        globalStatistics.addErrorSource( reportEntry.getName(), reportEntry.getStackTraceWriter() );
-        clearCapture();
-    }
-
-    public void testFailed( ReportEntry reportEntry )
-    {
-        multicastingReporter.testFailed(reportEntry, getAsString(testStdOut), getAsString(testStdErr));
-        testSetStatistics.incrementFailureCount();
-        testSetStatistics.incrementCompletedCount();
-        globalStatistics.addFailureSource(reportEntry.getName(), reportEntry.getStackTraceWriter());
-        clearCapture();
-    }
-
-    // ----------------------------------------------------------------------
-    // Counters
-    // ----------------------------------------------------------------------
-
-    public void testSkipped( ReportEntry report )
-    {
-        clearCapture();
-        testSetStatistics.incrementSkippedCount();
-        testSetStatistics.incrementCompletedCount();
-        multicastingReporter.testSkipped(report);
-    }
-
-    public void testAssumptionFailure( ReportEntry report )
-    {
-        testSkipped(report);
-    }
-
-    public String getAsString( List<ByteBuffer> byteBufferList )
-    {
-        StringBuilder stringBuffer = new StringBuilder();
-        // To avoid getting a java.util.ConcurrentModificationException while iterating (see SUREFIRE-879) we need to
-        // iterate over a copy or the elements array. Since the passed in byteBufferList is always wrapped with
-        // Collections.synchronizedList( ) we are guaranteed toArray() is going to be atomic, so we are safe.
-        for ( Object byteBuffer : byteBufferList.toArray() )
-        {
-            stringBuffer.append( byteBuffer.toString() );
-        }
-        return stringBuffer.toString();
-    }
-}
+package org.apache.maven.plugin.surefire.report;
+
+/*
+ * 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 java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.apache.maven.plugin.surefire.runorder.StatisticsReporter;
+import org.apache.maven.surefire.report.*;
+import org.apache.maven.surefire.util.internal.ByteBuffer;
+
+/**
+ * Reports data for a single test set.
+ * <p/>
+ */
+public class TestSetRunListener
+    implements RunListener, ConsoleOutputReceiver, ConsoleLogger
+{
+    private final TestSetStatistics testSetStatistics;
+
+    private final RunStatistics globalStatistics;
+
+    private final TestSetStats detailsForThis;
+
+    private final MulticastingReporter multicastingReporter;
+
+    private final List<ByteBuffer> testStdOut = Collections.synchronizedList( new ArrayList<ByteBuffer>() );
+
+    private final List<ByteBuffer> testStdErr = Collections.synchronizedList( new ArrayList<ByteBuffer>() );
+
+    private final TestcycleConsoleOutputReceiver consoleOutputReceiver;
+
+    public TestSetRunListener(AbstractConsoleReporter consoleReporter, AbstractFileReporter fileReporter,
+                              XMLReporter xmlReporter, TestcycleConsoleOutputReceiver consoleOutputReceiver, StatisticsReporter statisticsReporter,
+                              RunStatistics globalStats, boolean trimStackTrace)
+    {
+        List<Reporter> reporters = new ArrayList<Reporter>();
+        this.detailsForThis = new TestSetStats(trimStackTrace);
+        if ( consoleReporter != null )
+        {
+            reporters.add( consoleReporter );
+        }
+        if ( fileReporter != null )
+        {
+            reporters.add( fileReporter );
+        }
+        if ( xmlReporter != null )
+        {
+            reporters.add( xmlReporter );
+        }
+        if ( statisticsReporter != null )
+        {
+            reporters.add( statisticsReporter );
+        }
+
+        this.consoleOutputReceiver = consoleOutputReceiver;
+
+        multicastingReporter = new MulticastingReporter( reporters );
+        this.testSetStatistics = new TestSetStatistics();
+        this.globalStatistics = globalStats;
+    }
+
+    public void info( String message )
+    {
+        multicastingReporter.writeMessage( message );
+    }
+
+    public void writeTestOutput( byte[] buf, int off, int len, boolean stdout )
+    {
+        ByteBuffer byteBuffer = new ByteBuffer( buf, off, len );
+        if ( stdout )
+        {
+            testStdOut.add( byteBuffer );
+        }
+        else
+        {
+            testStdErr.add( byteBuffer );
+        }
+        consoleOutputReceiver.writeTestOutput( buf, off, len, stdout );
+    }
+
+    public void testSetStarting( ReportEntry report )
+    {
+        detailsForThis.testSetStart();
+        multicastingReporter.testSetStarting(report);
+        consoleOutputReceiver.testSetStarting( report);
+    }
+
+    public void clearCapture()
+    {
+        testStdErr.clear();
+        testStdOut.clear();
+    }
+
+    public void testSetCompleted( ReportEntry report )
+    {
+        multicastingReporter.testSetCompleted( report, detailsForThis);
+        consoleOutputReceiver.testSetCompleted( report);
+        detailsForThis.reset();
+        multicastingReporter.reset();
+        globalStatistics.add(testSetStatistics);
+        testSetStatistics.reset();
+    }
+
+    // ----------------------------------------------------------------------
+    // Test
+    // ----------------------------------------------------------------------
+
+    public void testStarting( ReportEntry report )
+    {
+        detailsForThis.testStart();
+        multicastingReporter.testStarting( report );
+    }
+
+    public void testSucceeded( ReportEntry reportEntry )
+    {
+        detailsForThis.testEnd();
+        testSetStatistics.incrementCompletedCount();
+        multicastingReporter.testSucceeded( reportEntry, detailsForThis);
+        clearCapture();
+    }
+
+    public void testError( ReportEntry reportEntry )
+    {
+        detailsForThis.incrementErrorsCount();
+        detailsForThis.testEnd();
+
+        multicastingReporter.testError( reportEntry, getAsString( testStdOut ), getAsString( testStdErr ), detailsForThis);
+        testSetStatistics.incrementErrorsCount();
+        testSetStatistics.incrementCompletedCount();
+        globalStatistics.addErrorSource( reportEntry.getName(), reportEntry.getStackTraceWriter() );
+        clearCapture();
+    }
+
+    public void testFailed( ReportEntry reportEntry )
+    {
+        detailsForThis.incrementFailureCount();
+        detailsForThis.testEnd();
+
+        multicastingReporter.testFailed(reportEntry, getAsString(testStdOut), getAsString(testStdErr),  detailsForThis);
+        testSetStatistics.incrementFailureCount();
+        testSetStatistics.incrementCompletedCount();
+        globalStatistics.addFailureSource(reportEntry.getName(), reportEntry.getStackTraceWriter());
+        clearCapture();
+    }
+
+    // ----------------------------------------------------------------------
+    // Counters
+    // ----------------------------------------------------------------------
+
+    public void testSkipped( ReportEntry reportEntry )
+    {
+        detailsForThis.incrementSkippedCount();
+        detailsForThis.testEnd();
+
+        clearCapture();
+        testSetStatistics.incrementSkippedCount();
+        testSetStatistics.incrementCompletedCount();
+        multicastingReporter.testSkipped(reportEntry,  detailsForThis);
+    }
+
+    public void testAssumptionFailure( ReportEntry report )
+    {
+        testSkipped(report);
+    }
+
+    public String getAsString( List<ByteBuffer> byteBufferList )
+    {
+        StringBuilder stringBuffer = new StringBuilder();
+        // To avoid getting a java.util.ConcurrentModificationException while iterating (see SUREFIRE-879) we need to
+        // iterate over a copy or the elements array. Since the passed in byteBufferList is always wrapped with
+        // Collections.synchronizedList( ) we are guaranteed toArray() is going to be atomic, so we are safe.
+        for ( Object byteBuffer : byteBufferList.toArray() )
+        {
+            stringBuffer.append( byteBuffer.toString() );
+        }
+        return stringBuffer.toString();
+    }
+}

Added: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetStats.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetStats.java?rev=1373562&view=auto
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetStats.java (added)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetStats.java Wed Aug 15 18:45:29 2012
@@ -0,0 +1,220 @@
+package org.apache.maven.plugin.surefire.report;
+/*
+ * 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.report.ReportEntry;
+import org.apache.maven.surefire.report.StackTraceWriter;
+
+import java.text.NumberFormat;
+import java.util.Locale;
+
+public class TestSetStats
+{
+    private final boolean trimStackTrace;
+
+    private long testSetStartAt;
+
+    private long testStartAt;
+
+    private long testEndAt;
+
+    private int completedCount;
+
+    private int errors;
+
+    private int failures;
+
+    private int skipped;
+
+    public TestSetStats( boolean trimStackTrace )
+    {
+        this.trimStackTrace = trimStackTrace;
+    }
+
+    public long getTestSetStartAt()
+    {
+        return testSetStartAt;
+    }
+
+    public int getElapsedSinceTestSetStart()
+    {
+        return (int) ( System.currentTimeMillis() - testSetStartAt );
+    }
+
+    public void testSetStart()
+    {
+        testSetStartAt = System.currentTimeMillis();
+    }
+
+    public void testStart()
+    {
+        testStartAt = System.currentTimeMillis();
+    }
+
+    public long testEnd()
+    {
+        incrementCompletedCount();
+        testEndAt = System.currentTimeMillis();
+        // SUREFIRE-398 skipped tests call endTest without calling testStarting
+        // if startTime = 0, set it to endTime, so the diff will be 0
+        if ( testStartAt == 0 )
+        {
+            testStartAt = testEndAt;
+        }
+        return testEndAt - testStartAt;
+    }
+
+    public synchronized void incrementCompletedCount()
+    {
+        completedCount += 1;
+    }
+
+    public synchronized void incrementErrorsCount()
+    {
+        errors += 1;
+    }
+
+    public synchronized void incrementFailureCount()
+    {
+        failures += 1;
+    }
+
+    public synchronized void incrementSkippedCount()
+    {
+        skipped += 1;
+    }
+
+    public synchronized void reset()
+    {
+        completedCount = 0;
+        errors = 0;
+        failures = 0;
+        skipped = 0;
+    }
+
+    public synchronized int getCompletedCount()
+    {
+        return completedCount;
+    }
+
+    public int getErrors()
+    {
+        return errors;
+    }
+
+    public int getFailures()
+    {
+        return failures;
+    }
+
+    public int getSkipped()
+    {
+        return skipped;
+    }
+
+    long getActualRunTime( ReportEntry reportEntry )
+    {
+        @SuppressWarnings( "deprecation" )
+        final Integer clientSpecifiedElapsed = reportEntry.getElapsed();
+        return clientSpecifiedElapsed != null ? clientSpecifiedElapsed : testEndAt - testStartAt;
+    }
+
+    private static final String TEST_SET_COMPLETED_PREFIX = "Tests run: ";
+
+    private final NumberFormat numberFormat = NumberFormat.getInstance( Locale.ENGLISH );
+
+    static final String NL = System.getProperty( "line.separator" );
+
+    private static final int MS_PER_SEC = 1000;
+
+
+    String elapsedTimeAsString( long runTime )
+    {
+        return numberFormat.format( (double) runTime / MS_PER_SEC );
+    }
+
+    public String getTestSetSummary( Integer elapsed )
+    {
+        StringBuilder buf = new StringBuilder();
+
+        buf.append( TEST_SET_COMPLETED_PREFIX );
+        buf.append( completedCount );
+        buf.append( ", Failures: " );
+        buf.append( failures );
+        buf.append( ", Errors: " );
+        buf.append( errors );
+        buf.append( ", Skipped: " );
+        buf.append( skipped );
+        buf.append( ", Time elaXpsed: " );
+        buf.append( elapsedTimeAsString( elapsed != null ? elapsed : getElapsedSinceTestSetStart() ) );
+        buf.append( " sec" );
+
+        if ( failures > 0 || errors > 0 )
+        {
+            buf.append( " <<< FAILURE!" );
+        }
+
+        buf.append( "\n" );
+
+        return buf.toString();
+    }
+
+    public String getElapsedTimeSummary( ReportEntry report )
+    {
+        StringBuilder reportContent = new StringBuilder();
+        reportContent.append( report.getName() );
+        reportContent.append( "  Time elapsed: " );
+        reportContent.append( getActualRunTime( report ) );
+        reportContent.append( " sec" );
+
+        return reportContent.toString();
+    }
+
+
+    public String getOutput( ReportEntry report, String msg )
+    {
+        StringBuilder buf = new StringBuilder();
+
+        buf.append( getElapsedTimeSummary( report ) );
+
+        buf.append( "  <<< " ).append( msg ).append( "!" ).append( NL );
+
+        buf.append( getStackTrace( report ) );
+
+        return buf.toString();
+    }
+
+    /**
+     * Returns stacktrace as String.
+     *
+     * @param report ReportEntry object.
+     * @return stacktrace as string.
+     */
+    public String getStackTrace( ReportEntry report )
+    {
+        StackTraceWriter writer = report.getStackTraceWriter();
+        if ( writer == null )
+        {
+            return null;
+        }
+        return this.trimStackTrace ? writer.writeTrimmedTraceToString() : writer.writeTraceToString();
+    }
+
+
+}

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/XMLReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/XMLReporter.java?rev=1373562&r1=1373561&r2=1373562&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/XMLReporter.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/XMLReporter.java Wed Aug 15 18:45:29 2012
@@ -33,7 +33,6 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
 import java.util.StringTokenizer;
-import org.apache.maven.surefire.report.DescriptionDecoder;
 import org.apache.maven.surefire.report.ReportEntry;
 import org.apache.maven.surefire.report.ReporterException;
 import org.apache.maven.surefire.report.SafeThrowable;
@@ -75,7 +74,7 @@ import org.codehaus.plexus.util.xml.Xpp3
  *      (not yet implemented by Ant 1.8.2)
  */
 public class XMLReporter
-    extends AbstractReporter
+    implements Reporter
 {
     private static final String LS = System.getProperty( "line.separator" );
 
@@ -87,18 +86,15 @@ public class XMLReporter
 
     private final List<Xpp3Dom> results = Collections.synchronizedList( new ArrayList<Xpp3Dom>() );
 
-    private static final DescriptionDecoder decoder = new DescriptionDecoder();
-
     private int elapsed = 0;
 
-    public XMLReporter( boolean trimStackTrace, File reportsDirectory )
+    public XMLReporter( File reportsDirectory )
     {
-        this( trimStackTrace, reportsDirectory, null );
+        this( reportsDirectory, null );
     }
 
-    public XMLReporter( boolean trimStackTrace, File reportsDirectory, String reportNameSuffix )
+    public XMLReporter( File reportsDirectory, String reportNameSuffix )
     {
-        super( trimStackTrace );
         this.reportsDirectory = reportsDirectory;
         this.deleteOnStarting = false;
         this.reportNameSuffix = reportNameSuffix;
@@ -112,8 +108,6 @@ public class XMLReporter
     public void testSetStarting( ReportEntry report )
         throws ReporterException
     {
-        super.testSetStarting( report );
-
         if ( deleteOnStarting )
         {
             final File reportFile = getReportFile( report );
@@ -121,24 +115,31 @@ public class XMLReporter
         }
     }
 
-    public void testSetCompleted( ReportEntry report )
-        throws ReporterException
+    void deleteIfExisting( File reportFile )
     {
-        super.testSetCompleted( report );
+        if ( reportFile.exists() )
+        {
+            //noinspection ResultOfMethodCallIgnored
+            reportFile.delete();
+        }
+    }
+
 
-        long runTime = elapsed > 0 ? elapsed : ( System.currentTimeMillis() - testSetStartTime );
+    public void testSetCompleted( ReportEntry report, TestSetStats testSetStats )
+        throws ReporterException
+    {
 
-        Xpp3Dom testSuite = createTestSuiteElement( report, runTime );
+        Xpp3Dom testSuite = createTestSuiteElement( report, testSetStats );
 
         showProperties( testSuite );
 
-        testSuite.setAttribute( "tests", String.valueOf( this.getNumTests() ) );
+        testSuite.setAttribute( "tests", String.valueOf( testSetStats.getCompletedCount() ) );
 
-        testSuite.setAttribute( "errors", String.valueOf( this.getNumErrors() ) );
+        testSuite.setAttribute( "errors", String.valueOf( testSetStats.getErrors() ) );
 
-        testSuite.setAttribute( "skipped", String.valueOf( this.getNumSkipped() ) );
+        testSuite.setAttribute( "skipped", String.valueOf( testSetStats.getSkipped() ) );
 
-        testSuite.setAttribute( "failures", String.valueOf( this.getNumFailures() ) );
+        testSuite.setAttribute( "failures", String.valueOf( testSetStats.getFailures() ) );
 
         for ( Object result : results )
         {
@@ -195,22 +196,28 @@ public class XMLReporter
         return reportFile;
     }
 
-    public void testSucceeded( ReportEntry report )
+    public void testSucceeded( ReportEntry report, TestSetStats testSetStats )
     {
-        super.testSucceeded( report );
+        Xpp3Dom testCase = createTestElement( report, testSetStats );
 
-        long runTime = getActualRunTime( report );
+        results.add( testCase );
+    }
 
-        Xpp3Dom testCase = createTestElement( report, runTime );
+    public void testStarting( ReportEntry report )
+    {
+    }
 
-        results.add( testCase );
+    static String getReportName( ReportEntry report )
+    {
+        final int i = report.getName().lastIndexOf( "(" );
+        return i > 0 ? report.getName().substring( 0, i ) : report.getName();
     }
 
-    private Xpp3Dom createTestElement( ReportEntry report, long runTime )
+    private Xpp3Dom createTestElement( ReportEntry report, TestSetStats runTime )
     {
         elapsed += report.getElapsed();
         Xpp3Dom testCase = new Xpp3Dom( "testcase" );
-        testCase.setAttribute( "name", decoder.getReportName( report ) );
+        testCase.setAttribute( "name", getReportName( report ) );
         if ( report.getGroup() != null )
         {
             testCase.setAttribute( "group", report.getGroup() );
@@ -226,59 +233,55 @@ public class XMLReporter
                 testCase.setAttribute( "classname", report.getSourceName() );
             }
         }
-        testCase.setAttribute( "time", elapsedTimeAsString( runTime ) );
+        testCase.setAttribute( "time", runTime.elapsedTimeAsString( runTime.getActualRunTime( report ) ) );
         return testCase;
     }
 
-    private Xpp3Dom createTestSuiteElement( ReportEntry report, long runTime )
+    private Xpp3Dom createTestSuiteElement( ReportEntry report, TestSetStats testSetStats )
     {
         Xpp3Dom testCase = new Xpp3Dom( "testsuite" );
 
         if ( reportNameSuffix != null && reportNameSuffix.length() > 0 )
         {
-            testCase.setAttribute( "name", decoder.getReportName( report ) + "(" + reportNameSuffix + ")" );
+            testCase.setAttribute( "name", getReportName( report ) + "(" + reportNameSuffix + ")" );
         }
         else
         {
-            testCase.setAttribute( "name", decoder.getReportName( report ) );
+            testCase.setAttribute( "name", getReportName( report ) );
         }
         if ( report.getGroup() != null )
         {
             testCase.setAttribute( "group", report.getGroup() );
         }
-        testCase.setAttribute( "time", elapsedTimeAsString( runTime ) );
+        long runTime = elapsed > 0 ? elapsed : ( System.currentTimeMillis() - testSetStats.getTestSetStartAt() );
+        testCase.setAttribute( "time", testSetStats.elapsedTimeAsString( runTime ) );
         return testCase;
     }
 
-    public void testError( ReportEntry report, String stdOut, String stdErr )
+    public void testError( ReportEntry report, String stdOut, String stdErr, TestSetStats testSetStats )
     {
-        super.testError( report, stdOut, stdErr );
-
-        writeTestProblems( report, stdOut, stdErr, "error" );
+        writeTestProblems( report, stdOut, stdErr, "error", testSetStats );
     }
 
-    public void testFailed( ReportEntry report, String stdOut, String stdErr )
+    public void testFailed( ReportEntry report, String stdOut, String stdErr, TestSetStats testSetStats )
     {
-        super.testFailed( report, stdOut, stdErr );
-
-        writeTestProblems( report, stdOut, stdErr, "failure" );
+        writeTestProblems( report, stdOut, stdErr, "failure", testSetStats );
     }
 
-    public void testSkipped( ReportEntry report )
+    public void testSkipped( ReportEntry report, TestSetStats testSetStats )
     {
-        super.testSkipped( report );
-        writeTestProblems( report, null, null, "skipped" );
+        writeTestProblems( report, null, null, "skipped", testSetStats );
     }
 
-    private void writeTestProblems( ReportEntry report, String stdOut, String stdErr, String name )
+    private void writeTestProblems( ReportEntry report, String stdOut, String stdErr, String name,
+                                    TestSetStats elapsedForTest )
     {
-        long runTime = getActualRunTime( report );
 
-        Xpp3Dom testCase = createTestElement( report, runTime );
+        Xpp3Dom testCase = createTestElement( report, elapsedForTest );
 
         Xpp3Dom element = createElement( testCase, name );
 
-        String stackTrace = getStackTrace( report );
+        String stackTrace = elapsedForTest.getStackTrace( report );
 
         if ( report.getMessage() != null && report.getMessage().length() > 0 )
         {
@@ -379,6 +382,5 @@ public class XMLReporter
     {
         results.clear();
         elapsed = 0;
-        super.reset();
     }
 }

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java?rev=1373562&r1=1373561&r2=1373562&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/runorder/StatisticsReporter.java Wed Aug 15 18:45:29 2012
@@ -22,6 +22,7 @@ package org.apache.maven.plugin.surefire
 import java.io.File;
 import java.io.FileNotFoundException;
 import org.apache.maven.plugin.surefire.report.Reporter;
+import org.apache.maven.plugin.surefire.report.TestSetStats;
 import org.apache.maven.surefire.report.ReportEntry;
 import org.apache.maven.surefire.util.NestedRuntimeException;
 
@@ -48,7 +49,7 @@ public class StatisticsReporter
     {
     }
 
-    public void testSetCompleted( ReportEntry report )
+    public void testSetCompleted( ReportEntry report, TestSetStats testSetStats )
     {
         try
         {
@@ -64,22 +65,22 @@ public class StatisticsReporter
     {
     }
 
-    public void testSucceeded( ReportEntry report )
+    public void testSucceeded( ReportEntry report, TestSetStats testSetStats )
     {
         newResults.add( existing.createNextGeneration( report ) );
     }
 
-    public void testSkipped( ReportEntry report )
+    public void testSkipped( ReportEntry report, TestSetStats testSetStats )
     {
         newResults.add( existing.createNextGeneration( report ) );
     }
 
-    public void testError( ReportEntry report, String stdOut, String stdErr )
+    public void testError( ReportEntry report, String stdOut, String stdErr, TestSetStats testSetStats )
     {
         newResults.add( existing.createNextGenerationFailure( report ) );
     }
 
-    public void testFailed( ReportEntry report, String stdOut, String stdErr )
+    public void testFailed( ReportEntry report, String stdOut, String stdErr, TestSetStats testSetStats )
     {
         newResults.add( existing.createNextGenerationFailure( report ) );
     }

Copied: maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/XMLReporterTest.java (from r1372903, maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/XMLReporterTest.java?p2=maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/XMLReporterTest.java&p1=maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java&r1=1372903&r2=1373562&rev=1373562&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/XMLReporterTest.java Wed Aug 15 18:45:29 2012
@@ -1,4 +1,4 @@
-package org.apache.maven.surefire.report;
+package org.apache.maven.plugin.surefire.report;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -20,7 +20,10 @@ package org.apache.maven.surefire.report
  */
 
 import java.io.File;
-import org.apache.maven.plugin.surefire.report.XMLReporter;
+
+import org.apache.maven.surefire.report.PojoStackTraceWriter;
+import org.apache.maven.surefire.report.ReportEntry;
+import org.apache.maven.surefire.report.SimpleReportEntry;
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 
 import junit.framework.AssertionFailedError;
@@ -36,15 +39,17 @@ public class XMLReporterTest
 
     private String message;
 
+    private TestSetStats stats;
+
     protected void setUp()
         throws Exception
     {
         super.setUp();
-        reporter = new XMLReporter( true, new File( "." ) );
+        reporter = new XMLReporter( new File( "." ) );
         message = "junit.framework.AssertionFailedError";
         reportEntry = new SimpleReportEntry( this.getClass().getName(), "XMLReporterTest",
-                                             new PojoStackTraceWriter( "", "", new AssertionFailedError() ),
-                                             new Integer( 17 ) );
+                                             new PojoStackTraceWriter( "", "", new AssertionFailedError() ), 17 );
+        stats = new TestSetStats( false );
     }
 
     /*
@@ -52,7 +57,7 @@ public class XMLReporterTest
      */
     public void testTestError()
     {
-        reporter.testError( reportEntry, "", "" );
+        reporter.testError( reportEntry, "", "", stats );
         assertResult( reporter, message );
     }
 
@@ -61,7 +66,7 @@ public class XMLReporterTest
      */
     public void testTestFailed()
     {
-        reporter.testError( reportEntry, "", "" );
+        reporter.testError( reportEntry, "", "", stats );
         assertResult( reporter, message );
     }
 
@@ -78,14 +83,15 @@ public class XMLReporterTest
     public void testFileNameWithoutSuffix()
     {
         File reportDir = new File( "." );
-        String testName = "org.apache.maven.surefire.report.XMLReporterTest";
-        reportEntry = new SimpleReportEntry( this.getClass().getName(), testName, new Integer( 12 ) );
-        reporter = new XMLReporter( true, reportDir, null );
-        reporter.testSetCompleted( reportEntry );
+        String testName = "org.apache.maven.plugin.surefire.report.XMLReporterTest";
+        reportEntry = new SimpleReportEntry( this.getClass().getName(), testName, 12 );
+        reporter = new XMLReporter( reportDir, null );
+        reporter.testSetCompleted( reportEntry, stats );
 
         File expectedReportFile = new File( reportDir, "TEST-" + testName + ".xml" );
         assertTrue( "Report file (" + expectedReportFile.getAbsolutePath() + ") doesn't exist",
                     expectedReportFile.exists() );
+        //noinspection ResultOfMethodCallIgnored
         expectedReportFile.delete();
     }
 
@@ -95,16 +101,43 @@ public class XMLReporterTest
     public void testFileNameWithSuffix()
     {
         File reportDir = new File( "target" );
-        String testName = "org.apache.maven.surefire.report.XMLReporterTest";
+        String testName = "org.apache.maven.plugin.surefire.report.XMLReporterTest";
         String suffixText = "sampleSuffixText";
         reportEntry = new SimpleReportEntry( this.getClass().getName(), testName );
-        reporter = new XMLReporter( true, reportDir, suffixText );
-        reporter.testSetCompleted( reportEntry );
+        reporter = new XMLReporter( reportDir, suffixText );
+        reporter.testSetCompleted( reportEntry, stats );
 
         File expectedReportFile = new File( reportDir, "TEST-" + testName + "-" + suffixText + ".xml" );
         assertTrue( "Report file (" + expectedReportFile.getAbsolutePath() + ") doesn't exist",
                     expectedReportFile.exists() );
+        //noinspection ResultOfMethodCallIgnored
         expectedReportFile.delete();
     }
 
+    public void testGetReportNameWithParams()
+        throws Exception
+    {
+        String category = "[0] 1\u002C 2\u002C 3 (testSum)(surefire.testcase.JunitParamsTest)";
+        ReportEntry reportEntry = new SimpleReportEntry( "fud", category );
+        final String reportName = XMLReporter.getReportName( reportEntry );
+        assertEquals( "[0] 1, 2, 3 (testSum)", reportName );
+    }
+
+    public void testClassNameOnly()
+        throws Exception
+    {
+        String category = "surefire.testcase.JunitParamsTest";
+        ReportEntry reportEntry = new SimpleReportEntry( "fud", category );
+        final String reportName = XMLReporter.getReportName( reportEntry );
+        assertEquals( "surefire.testcase.JunitParamsTest", reportName );
+    }
+
+    public void testRegular()
+    {
+        ReportEntry reportEntry = new SimpleReportEntry( "fud", "testSum(surefire.testcase.NonJunitParamsTest)" );
+        final String reportName = XMLReporter.getReportName( reportEntry );
+        assertEquals( "testSum", reportName );
+    }
+
+
 }

Modified: maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java?rev=1373562&r1=1373561&r2=1373562&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java Wed Aug 15 18:45:29 2012
@@ -41,7 +41,7 @@ public class FileReporterTest
     {
         File reportDir = new File( "target" );
         reportEntry = new SimpleReportEntry( this.getClass().getName(), testName );
-        reporter = new FileReporter( true, reportDir, null );
+        reporter = new FileReporter( reportDir, null );
         reporter.testSetStarting( reportEntry );
 
         File expectedReportFile = new File( reportDir, testName + ".txt" );
@@ -58,7 +58,7 @@ public class FileReporterTest
         File reportDir = new File( "target" );
         String suffixText = "sampleSuffixText";
         reportEntry = new SimpleReportEntry( this.getClass().getName(), testName );
-        reporter = new FileReporter( true, reportDir, suffixText );
+        reporter = new FileReporter( reportDir, suffixText );
         reporter.testSetStarting( reportEntry );
 
         File expectedReportFile = new File( reportDir, testName + "-" + suffixText + ".txt" );