You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by br...@apache.org on 2005/10/03 02:57:08 UTC

svn commit: r293194 - /maven/components/trunk/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test/SurefirePlugin.java

Author: brett
Date: Sun Oct  2 17:57:04 2005
New Revision: 293194

URL: http://svn.apache.org/viewcvs?rev=293194&view=rev
Log:
PR: MNG-978, 979, 964
Submitted by: Johnny R. Ruiz III
Reviewed by:  Brett Porter
added parameters printSummary, reportFormat, and useFile to configure the reporting format.

Modified:
    maven/components/trunk/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test/SurefirePlugin.java

Modified: maven/components/trunk/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test/SurefirePlugin.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test/SurefirePlugin.java?rev=293194&r1=293193&r2=293194&view=diff
==============================================================================
--- maven/components/trunk/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test/SurefirePlugin.java (original)
+++ maven/components/trunk/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test/SurefirePlugin.java Sun Oct  2 17:57:04 2005
@@ -141,6 +141,30 @@
      * @parameter expression="${plugin.artifacts}"
      */
     private List pluginArtifacts;
+    
+    /**
+     * Option to print summary of test suites or just print the test cases that has errors.
+     * 
+     *  @parameter expression="${surefire.printSummary}"
+     *             default-value="true"
+     */
+    private boolean printSummary;
+    
+    /**
+     * Selects the formatting for the test report to be generated.  Can be set as brief, plain, or xml.
+     * 
+     * @parameter expression="${surefire.reportFormat}"
+     *            default-value="brief"       
+     */
+     private String reportFormat;
+     
+     /**
+      * Option to generate a file test report or just output the test report to the console.
+      * 
+      * @parameter expression="${surefire.useFile}"
+      *            default-value="true"
+      */
+     private boolean useFile;
 
     public void execute()
         throws MojoExecutionException
@@ -253,13 +277,8 @@
             surefireBooter.addClassPathUrl( artifact.getFile().getAbsolutePath() );
         }
 
-        surefireBooter.addReport( "org.codehaus.surefire.report.ConsoleReporter" );
-
-        surefireBooter.addReport( "org.codehaus.surefire.report.FileReporter" );
-
-        surefireBooter.addReport( "org.codehaus.surefire.report.XMLReporter");
-
-
+        addReporters(surefireBooter);
+        
         boolean success;
 
         try
@@ -344,5 +363,49 @@
         }
 
         return list;
+    }
+    
+    /**
+     * <p> Adds Reporters that will generate reports with different formatting. 
+     * <p> The Reporter that will be added will be based on the value of the parameter 
+     *     useFile, reportFormat, and printSummary.
+     *     
+     * @param surefireBooter The surefire booter that will run tests.
+     */
+    private void addReporters(SurefireBooter surefireBooter)
+    {
+
+        if ( useFile )
+        {
+            if ( printSummary )
+            {
+                surefireBooter.addReport( "org.codehaus.surefire.report.ConsoleReporter" );
+            }
+            else
+            {
+                surefireBooter.addReport( "org.codehaus.surefire.report.SummaryConsoleReporter" );
+            }
+
+            if ( reportFormat.equals( "brief" ) )
+            {
+                surefireBooter.addReport( "org.codehaus.surefire.report.BriefFileReporter" );
+            }
+            else if ( reportFormat.equals( "plain" ) )
+            {
+                surefireBooter.addReport( "org.codehaus.surefire.report.FileReporter" );
+            }
+        }
+        else
+        {
+            if ( reportFormat.equals( "brief" ) )
+            {
+                surefireBooter.addReport( "org.codehaus.surefire.report.BriefConsoleReporter" );
+            }
+            else if ( reportFormat.equals( "plain" ) )
+            {
+                surefireBooter.addReport( "org.codehaus.surefire.report.DetailedConsoleReporter" );
+            }
+        }
+        surefireBooter.addReport( "org.codehaus.surefire.report.XMLReporter" );   
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org