From 5c48727b1867e6f7f437c8bb4f08e6a21bc949dd Mon Sep 17 00:00:00 2001 From: Brett Leslie Porter Date: Mon, 3 Oct 2005 00:57:04 +0000 Subject: [PATCH] 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. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@293194 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/maven/test/SurefirePlugin.java | 77 +++++++++++++++++-- 1 file changed, 70 insertions(+), 7 deletions(-) diff --git a/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test/SurefirePlugin.java b/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test/SurefirePlugin.java index 6095d348e9..7a37e1f681 100644 --- a/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test/SurefirePlugin.java +++ b/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test/SurefirePlugin.java @@ -141,6 +141,30 @@ public class SurefirePlugin * @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 @@ public class SurefirePlugin 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 @@ -345,4 +364,48 @@ public class SurefirePlugin return list; } + + /** + *

Adds Reporters that will generate reports with different formatting. + *

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" ); + } }