You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by pg...@apache.org on 2011/07/05 23:37:58 UTC

svn commit: r1143207 - in /maven/surefire/trunk: maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/ maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ maven-surefire-plugin/src/main/java/org/apache/maven/plugin/sur...

Author: pgier
Date: Tue Jul  5 21:37:57 2011
New Revision: 1143207

URL: http://svn.apache.org/viewvc?rev=1143207&view=rev
Log:
[SUREFIRE-750] Add optional suffix for surefire reports
Submitted By: Rostislav Svoboda

o Applied with minor changes

Added:
    maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/ConsoleOutputFileReporterTest.java   (with props)
    maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java   (with props)
Modified:
    maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java
    maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/StartupReportConfiguration.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractFileReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/BriefFileReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleOutputFileReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/FileReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java
    maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java

Modified: maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java?rev=1143207&r1=1143206&r2=1143207&view=diff
==============================================================================
--- maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java (original)
+++ maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java Tue Jul  5 21:37:57 2011
@@ -317,6 +317,16 @@ public class IntegrationTestMojo
     private String reportFormat;
 
     /**
+     * Add custom text into report filename: TEST-testClassName-reportNameSuffix.xml,
+     * testClassName-reportNameSuffix.txt and testClassName-reportNameSuffix-output.txt.
+     * File TEST-testClassName-reportNameSuffix.xml has changed attributes 'testsuite'--'name'
+     * and 'testcase'--'classname' - reportNameSuffix is added to the attribute value.
+     *
+     * @parameter expression="${surefire.reportNameSuffix}" default-value=""
+     */
+    private String reportNameSuffix;
+
+    /**
      * Option to generate a file test report or just output the test report to the console.
      *
      * @parameter expression="${failsafe.useFile}" default-value="true"
@@ -1001,6 +1011,16 @@ public class IntegrationTestMojo
         this.reportFormat = reportFormat;
     }
 
+    public String getReportNameSuffix()
+    {
+        return reportNameSuffix;
+    }
+
+    public void setReportNameSuffix( String reportNameSuffix )
+    {
+        this.reportNameSuffix = reportNameSuffix;
+    }
+
     public boolean isUseFile()
     {
         return useFile;

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java?rev=1143207&r1=1143206&r2=1143207&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java Tue Jul  5 21:37:57 2011
@@ -426,7 +426,7 @@ public abstract class AbstractSurefireMo
     {
         return new StartupReportConfiguration( isUseFile(), isPrintSummary(), getReportFormat(),
                                                isRedirectTestOutputToFile(), isDisableXmlReport(),
-                                               getReportsDirectory(), isTrimStackTrace() );
+                                               getReportsDirectory(), isTrimStackTrace(), getReportNameSuffix() );
     }
 
     void logClasspath( Classpath classpath, String descriptor )
@@ -736,6 +736,7 @@ public abstract class AbstractSurefireMo
         checksum.add( getProperties() );
         checksum.add( isPrintSummary() );
         checksum.add( getReportFormat() );
+        checksum.add( getReportNameSuffix() );
         checksum.add( isUseFile() );
         checksum.add( isRedirectTestOutputToFile() );
         checksum.add( getForkMode() );

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java?rev=1143207&r1=1143206&r2=1143207&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java Tue Jul  5 21:37:57 2011
@@ -138,6 +138,10 @@ public interface SurefireExecutionParame
 
     void setReportFormat( String reportFormat );
 
+    String getReportNameSuffix();
+
+    void setReportNameSuffix( String reportNameSuffix );
+
     boolean isUseFile();
 
     void setUseFile( boolean useFile );

Modified: maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java?rev=1143207&r1=1143206&r2=1143207&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java (original)
+++ maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java Tue Jul  5 21:37:57 2011
@@ -286,6 +286,16 @@ public class SurefirePlugin
     private String reportFormat;
 
     /**
+     * Add custom text into report filename: TEST-testClassName-reportNameSuffix.xml,
+     * testClassName-reportNameSuffix.txt and testClassName-reportNameSuffix-output.txt.
+     * File TEST-testClassName-reportNameSuffix.xml has changed attributes 'testsuite'--'name'
+     * and 'testcase'--'classname' - reportNameSuffix is added to the attribute value.
+     *
+     * @parameter expression="${surefire.reportNameSuffix}" default-value=""
+     */
+    private String reportNameSuffix;
+
+    /**
      * Option to generate a file test report or just output the test report to the console.
      *
      * @parameter expression="${surefire.useFile}" default-value="true"
@@ -936,6 +946,16 @@ public class SurefirePlugin
         this.reportFormat = reportFormat;
     }
 
+    public String getReportNameSuffix()
+    {
+        return reportNameSuffix;
+    }
+
+    public void setReportNameSuffix( String reportNameSuffix )
+    {
+        this.reportNameSuffix = reportNameSuffix;
+    }
+
     public boolean isUseFile()
     {
         return useFile;

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/StartupReportConfiguration.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/StartupReportConfiguration.java?rev=1143207&r1=1143206&r2=1143207&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/StartupReportConfiguration.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/StartupReportConfiguration.java Tue Jul  5 21:37:57 2011
@@ -51,6 +51,8 @@ public class StartupReportConfiguration
 
     private final String reportFormat;
 
+    private final String reportNameSuffix;
+
     private final boolean redirectTestOutputToFile;
 
     private final boolean disableXmlReport;
@@ -69,6 +71,15 @@ public class StartupReportConfiguration
                                        boolean redirectTestOutputToFile, boolean disableXmlReport,
                                        File reportsDirectory, boolean trimStackTrace )
     {
+        this( useFile, printSummary, reportFormat, redirectTestOutputToFile, 
+                disableXmlReport, reportsDirectory, trimStackTrace, null );
+    }
+
+    public StartupReportConfiguration( boolean useFile, boolean printSummary, String reportFormat,
+                                       boolean redirectTestOutputToFile, boolean disableXmlReport,
+                                       File reportsDirectory, boolean trimStackTrace,
+                                       String reportNameSuffix )
+    {
         this.useFile = useFile;
         this.printSummary = printSummary;
         this.reportFormat = reportFormat;
@@ -76,6 +87,7 @@ public class StartupReportConfiguration
         this.disableXmlReport = disableXmlReport;
         this.reportsDirectory = reportsDirectory;
         this.trimStackTrace = trimStackTrace;
+        this.reportNameSuffix = reportNameSuffix;
     }
 
     public static StartupReportConfiguration defaultValue()
@@ -105,6 +117,11 @@ public class StartupReportConfiguration
         return reportFormat;
     }
 
+    public String getReportNameSuffix()
+    {
+        return reportNameSuffix;
+    }
+
     public boolean isRedirectTestOutputToFile()
     {
         return redirectTestOutputToFile;
@@ -133,7 +150,7 @@ public class StartupReportConfiguration
     {
         if ( !isDisableXmlReport() )
         {
-            return new XMLReporter(trimStackTrace, reportsDirectory);
+            return new XMLReporter(trimStackTrace, reportsDirectory, reportNameSuffix);
         }
         return null;
     }
@@ -160,11 +177,11 @@ public class StartupReportConfiguration
         {
             if ( BRIEF_REPORT_FORMAT.equals( getReportFormat() ) )
             {
-                return new BriefFileReporter(trimStackTrace, reportsDirectory);
+                return new BriefFileReporter(trimStackTrace, reportsDirectory, getReportNameSuffix());
             }
             else if ( PLAIN_REPORT_FORMAT.equals( getReportFormat() ) )
             {
-                return new FileReporter(trimStackTrace, reportsDirectory);
+                return new FileReporter(trimStackTrace, reportsDirectory, getReportNameSuffix());
             }
         }
         return null;
@@ -226,7 +243,7 @@ public class StartupReportConfiguration
     {
         if ( isRedirectTestOutputToFile() )
         {
-            return new ConsoleOutputFileReporter(reportsDirectory);
+            return new ConsoleOutputFileReporter(reportsDirectory, getReportNameSuffix());
         }
         else
         {

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java?rev=1143207&r1=1143206&r2=1143207&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java Tue Jul  5 21:37:57 2011
@@ -204,7 +204,7 @@ public class SurefireReflector
         Constructor constructor = ReflectionUtils.getConstructor( this.startupReportConfiguration,
                                                                   new Class[]{ boolean.class, boolean.class,
                                                                       String.class, boolean.class, boolean.class,
-                                                                      File.class, boolean.class } );
+                                                                      File.class, boolean.class, String.class } );
         //noinspection BooleanConstructorCall
         final Object[] params =
             { new Boolean( reporterConfiguration.isUseFile() ), new Boolean( reporterConfiguration.isPrintSummary() ),
@@ -212,7 +212,8 @@ public class SurefireReflector
                 new Boolean( reporterConfiguration.isRedirectTestOutputToFile() ),
                 new Boolean( reporterConfiguration.isDisableXmlReport() ),
                 reporterConfiguration.getReportsDirectory(),
-                new Boolean( reporterConfiguration.isTrimStackTrace())};
+                new Boolean( reporterConfiguration.isTrimStackTrace()),
+                reporterConfiguration.getReportNameSuffix()};
         return ReflectionUtils.newInstance( constructor, params );
     }
 

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractFileReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractFileReporter.java?rev=1143207&r1=1143206&r2=1143207&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractFileReporter.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractFileReporter.java Tue Jul  5 21:37:57 2011
@@ -36,11 +36,19 @@ public abstract class AbstractFileReport
 
     private final boolean deleteOnStarting;
 
+    private final String reportNameSuffix;
+
     AbstractFileReporter( boolean trimStackTrace, String format, File reportsDirectory )
     {
+        this( trimStackTrace, format, reportsDirectory, null );
+    }
+    
+    AbstractFileReporter( boolean trimStackTrace, String format, File reportsDirectory, String reportNameSuffix )
+    {
         super( trimStackTrace, format );
         this.reportsDirectory = reportsDirectory;
         this.deleteOnStarting = false;
+        this.reportNameSuffix = reportNameSuffix;
     }
 
     public void testSetStarting( ReportEntry report )
@@ -48,7 +56,7 @@ public abstract class AbstractFileReport
     {
         super.testSetStarting( report );
 
-        File reportFile = getReportFile( report );
+        File reportFile = getReportFile( reportsDirectory, report.getName(), reportNameSuffix, ".txt" );
 
         File reportDir = reportFile.getParentFile();
 
@@ -79,9 +87,20 @@ public abstract class AbstractFileReport
         }
     }
 
-    private File getReportFile( ReportEntry report )
+    public static File getReportFile( File reportsDirectory, String reportEntryName, 
+            String reportNameSuffix, String fileExtension )
     {
-        return new File( reportsDirectory, report.getName() + ".txt" );
+        File reportFile;
+
+        if ( reportNameSuffix != null && reportNameSuffix.length() > 0)
+        {
+            reportFile = new File( reportsDirectory, reportEntryName + "-" + reportNameSuffix + fileExtension );
+        }
+        else
+        {
+            reportFile = new File( reportsDirectory, reportEntryName + fileExtension );
+        }
+        return reportFile;
     }
 
     public void testSetCompleted( ReportEntry report )

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/BriefFileReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/BriefFileReporter.java?rev=1143207&r1=1143206&r2=1143207&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/BriefFileReporter.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/BriefFileReporter.java Tue Jul  5 21:37:57 2011
@@ -35,4 +35,9 @@ public class BriefFileReporter
     {
         super( trimStackTrace, BRIEF, reportsDirectory );
     }
+    
+    public BriefFileReporter( boolean trimStackTrace, File reportsDirectory, String reportNameSuffix )
+    {
+        super( trimStackTrace, BRIEF, reportsDirectory, reportNameSuffix );
+    }
 }

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleOutputFileReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleOutputFileReporter.java?rev=1143207&r1=1143206&r2=1143207&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleOutputFileReporter.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleOutputFileReporter.java Tue Jul  5 21:37:57 2011
@@ -48,9 +48,19 @@ public class ConsoleOutputFileReporter
 
     private String reportEntryName;
 
+    private ReportEntry report;
+
+    private final String reportNameSuffix;
+
     public ConsoleOutputFileReporter( File reportsDirectory )
     {
+        this( reportsDirectory, null );
+    }
+
+    public ConsoleOutputFileReporter( File reportsDirectory, String reportNameSuffix )
+    {
         this.reportsDirectory = reportsDirectory;
+        this.reportNameSuffix = reportNameSuffix;
     }
 
     public void testSetStarting( ReportEntry reportEntry )
@@ -79,7 +89,7 @@ public class ConsoleOutputFileReporter
                     //noinspection ResultOfMethodCallIgnored
                     reportsDirectory.mkdirs();
                 }
-                File file = new File( reportsDirectory, reportEntryName + "-output.txt" );
+                File file = AbstractFileReporter.getReportFile( reportsDirectory, reportEntryName, reportNameSuffix, "-output.txt" );
                 printWriter = new PrintWriter( new BufferedWriter( new FileWriter( file ) ) );
             }
             printWriter.write( new String( b, off, len ) );

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/FileReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/FileReporter.java?rev=1143207&r1=1143206&r2=1143207&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/FileReporter.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/FileReporter.java Tue Jul  5 21:37:57 2011
@@ -35,4 +35,9 @@ public class FileReporter
     {
         super( trimStackTrace, PLAIN, reportsDirectory );
     }
+    
+    public FileReporter( boolean trimStackTrace, File reportsDirectory, String reportNamePrefix )
+    {
+        super( trimStackTrace, PLAIN, reportsDirectory, reportNamePrefix);
+    }
 }

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java?rev=1143207&r1=1143206&r2=1143207&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java Tue Jul  5 21:37:57 2011
@@ -52,14 +52,22 @@ public class XMLReporter
 
     private final boolean deleteOnStarting;
 
+    private final String reportNameSuffix;
+
     private final List results = Collections.synchronizedList( new ArrayList() );
 
 
     public XMLReporter( boolean trimStackTrace, File reportsDirectory )
     {
+        this( trimStackTrace, reportsDirectory, null );
+    }
+
+    public XMLReporter( boolean trimStackTrace, File reportsDirectory, String reportNameSuffix )
+    {
         super( trimStackTrace );
         this.reportsDirectory = reportsDirectory;
         this.deleteOnStarting = false;
+        this.reportNameSuffix = reportNameSuffix;
     }
 
 
@@ -144,7 +152,18 @@ public class XMLReporter
 
     private File getReportFile( ReportEntry report )
     {
-        return new File( reportsDirectory, "TEST-" + report.getName() + ".xml" );
+        File reportFile;
+
+        if ( reportNameSuffix != null && reportNameSuffix.length() > 0)
+        {
+            reportFile = new File( reportsDirectory, "TEST-" + report.getName() + "-" + reportNameSuffix + ".xml" );
+        }
+        else
+        {
+            reportFile = new File( reportsDirectory, "TEST-" + report.getName() + ".xml" );
+        }
+
+        return reportFile;
     }
 
     private String getReportName( ReportEntry report )
@@ -183,7 +202,14 @@ public class XMLReporter
         }
         if ( report.getSourceName() != null )
         {
-            testCase.setAttribute( "classname", report.getSourceName() );
+            if ( reportNameSuffix != null && reportNameSuffix.length() > 0)
+            {
+                testCase.setAttribute( "classname", report.getSourceName() + "(" + reportNameSuffix + ")" );
+            }
+            else
+            {
+                testCase.setAttribute( "classname", report.getSourceName() );
+            }
         }
         testCase.setAttribute( "time", elapsedTimeAsString( runTime ) );
         return testCase;
@@ -192,7 +218,15 @@ public class XMLReporter
     private Xpp3Dom createTestSuiteElement( ReportEntry report, long runTime )
     {
         Xpp3Dom testCase = new Xpp3Dom( "testsuite" );
-        testCase.setAttribute( "name", getReportName( report ) );
+
+        if ( reportNameSuffix != null && reportNameSuffix.length() > 0)
+        {
+            testCase.setAttribute( "name", getReportName( report ) + "(" + reportNameSuffix + ")" );
+        }
+        else
+        {
+            testCase.setAttribute( "name", getReportName( report ) );
+        }
         if ( report.getGroup() != null )
         {
             testCase.setAttribute( "group", report.getGroup() );

Added: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/ConsoleOutputFileReporterTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/ConsoleOutputFileReporterTest.java?rev=1143207&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/ConsoleOutputFileReporterTest.java (added)
+++ maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/ConsoleOutputFileReporterTest.java Tue Jul  5 21:37:57 2011
@@ -0,0 +1,70 @@
+package org.apache.maven.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.io.File;
+import junit.framework.TestCase;
+
+public class ConsoleOutputFileReporterTest
+    extends TestCase
+{
+
+    private ConsoleOutputFileReporter reporter;
+
+    private ReportEntry reportEntry;
+
+    private static final String testName = "org.apache.maven.surefire.report.ConsoleOutputFileReporterTest";
+
+    /*
+     * Test method for 'org.codehaus.surefire.report.ConsoleOutputFileReporter.testSetCompleted(ReportEntry report)'
+     */
+    public void testFileNameWithoutSuffix()
+    {
+        File reportDir = new File( System.getProperty( "java.io.tmpdir" ) );
+        reportEntry = new SimpleReportEntry( this.getClass().getName(), testName );
+        reporter = new ConsoleOutputFileReporter( reportDir );
+        reporter.testSetStarting( reportEntry );
+        reporter.writeMessage( "some text".getBytes(), 0, 5 );
+        reporter.testSetCompleted( reportEntry );
+
+        File expectedReportFile = new File( reportDir, testName + "-output.txt" );
+        assertTrue("Report file (" + expectedReportFile.getAbsolutePath() + ") doesn't exist",  expectedReportFile.exists() );
+        expectedReportFile.delete();
+    }
+
+    /*
+     * Test method for 'org.codehaus.surefire.report.ConsoleOutputFileReporter.testSetCompleted(ReportEntry report)'
+     */
+    public void testFileNameWithSuffix()
+    {
+        File reportDir = new File( System.getProperty( "java.io.tmpdir" ) );
+        String suffixText = "sampleSuffixText";
+        reportEntry = new SimpleReportEntry( this.getClass().getName(), testName );
+        reporter = new ConsoleOutputFileReporter( reportDir, suffixText );
+        reporter.testSetStarting( reportEntry );
+        reporter.writeMessage( "some text".getBytes(), 0, 5 );
+        reporter.testSetCompleted( reportEntry );
+
+        File expectedReportFile = new File( reportDir, testName + "-" + suffixText + "-output.txt" );
+        assertTrue("Report file (" + expectedReportFile.getAbsolutePath() + ") doesn't exist",  expectedReportFile.exists() );
+        expectedReportFile.delete();
+    }
+
+}

Propchange: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/ConsoleOutputFileReporterTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/ConsoleOutputFileReporterTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java?rev=1143207&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java (added)
+++ maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java Tue Jul  5 21:37:57 2011
@@ -0,0 +1,66 @@
+package org.apache.maven.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.io.File;
+import junit.framework.TestCase;
+
+public class FileReporterTest
+    extends TestCase
+{
+
+    private FileReporter reporter;
+
+    private ReportEntry reportEntry;
+
+    private static final String testName = "org.apache.maven.surefire.report.FileReporterTest";
+
+    /*
+     * Test method for 'org.codehaus.surefire.report.FileReporter.testSetStarting(ReportEntry report)'
+     */
+    public void testFileNameWithoutSuffix()
+    {
+        File reportDir = new File( "." );
+        reportEntry = new SimpleReportEntry( this.getClass().getName(), testName );
+        reporter = new FileReporter( true, reportDir, null );
+        reporter.testSetStarting( reportEntry );
+
+        File expectedReportFile = new File( reportDir, testName + ".txt" );
+        assertTrue("Report file (" + expectedReportFile.getAbsolutePath() + ") doesn't exist",  expectedReportFile.exists() );
+        expectedReportFile.delete();
+    }
+
+    /*
+     * Test method for 'org.codehaus.surefire.report.FileReporter.testSetStarting(ReportEntry report)'
+     */
+    public void testFileNameWithSuffix()
+    {
+        File reportDir = new File( "." );
+        String suffixText = "sampleSuffixText";
+        reportEntry = new SimpleReportEntry( this.getClass().getName(), testName );
+        reporter = new FileReporter( true, reportDir, suffixText );
+        reporter.testSetStarting( reportEntry );
+
+        File expectedReportFile = new File( reportDir, testName + "-" + suffixText + ".txt" );
+        assertTrue("Report file (" + expectedReportFile.getAbsolutePath() + ") doesn't exist",  expectedReportFile.exists() );
+        expectedReportFile.delete();
+    }
+
+}

Propchange: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java?rev=1143207&r1=1143206&r2=1143207&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java (original)
+++ maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java Tue Jul  5 21:37:57 2011
@@ -70,4 +70,37 @@ public class XMLReporterTest
         assertEquals( message, child.getAttribute( "type" ) );
     }
 
+    /*
+     * Test method for 'org.codehaus.surefire.report.XMLReporter.testSetCompleted(ReportEntry report)'
+     */
+    public void testFileNameWithoutSuffix()
+    {
+        File reportDir = new File( "." );
+        String testName = "org.apache.maven.surefire.report.XMLReporterTest";
+        reportEntry = new SimpleReportEntry( this.getClass().getName(), testName );
+        reporter = new XMLReporter( true, reportDir, null );
+        reporter.testSetCompleted( reportEntry );
+
+        File expectedReportFile = new File( reportDir, "TEST-" + testName + ".xml" );
+        assertTrue("Report file (" + expectedReportFile.getAbsolutePath() + ") doesn't exist",  expectedReportFile.exists() );
+        expectedReportFile.delete();
+    }
+
+    /*
+     * Test method for 'org.codehaus.surefire.report.XMLReporter.testSetCompleted(ReportEntry report)'
+     */
+    public void testFileNameWithSuffix()
+    {
+        File reportDir = new File( "." );
+        String testName = "org.apache.maven.surefire.report.XMLReporterTest";
+        String suffixText = "sampleSuffixText";
+        reportEntry = new SimpleReportEntry( this.getClass().getName(), testName );
+        reporter = new XMLReporter( true, reportDir, suffixText );
+        reporter.testSetCompleted( reportEntry );
+
+        File expectedReportFile = new File( reportDir, "TEST-" + testName + "-" + suffixText + ".xml" );
+        assertTrue("Report file (" + expectedReportFile.getAbsolutePath() + ") doesn't exist",  expectedReportFile.exists() );
+        expectedReportFile.delete();
+    }
+
 }