continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r703056 - in /continuum/branches/continuum-1.2.x: continuum-core/src/main/resources/org/apache/maven/continuum/notification/mail/templates/ continuum-reports/src/main/java/org/apache/maven/continuum/reports/surefire/ continuum-reports/src/t...
Date Thu, 09 Oct 2008 04:57:19 GMT
Author: evenisse
Date: Wed Oct  8 21:57:18 2008
New Revision: 703056

URL: http://svn.apache.org/viewvc?rev=703056&view=rev
Log:
[CONTINUUM-1694] Adding Number of Errors and Test Success Rate to Notification Email
Submitted by: Murali Mohan

Modified:
    continuum/branches/continuum-1.2.x/continuum-core/src/main/resources/org/apache/maven/continuum/notification/mail/templates/common.vm
    continuum/branches/continuum-1.2.x/continuum-reports/src/main/java/org/apache/maven/continuum/reports/surefire/DefaultReportTestSuiteGenerator.java
    continuum/branches/continuum-1.2.x/continuum-reports/src/main/java/org/apache/maven/continuum/reports/surefire/ReportTestResult.java
    continuum/branches/continuum-1.2.x/continuum-reports/src/main/java/org/apache/maven/continuum/reports/surefire/ReportTestSuite.java
    continuum/branches/continuum-1.2.x/continuum-reports/src/test/java/org/apache/maven/continuum/reports/surefire/DefaultReportTestSuiteGeneratorTest.java
    continuum/branches/continuum-1.2.x/continuum-reports/src/test/resources/continuum-core/TEST-org.apache.maven.continuum.scm.ContinuumScmTest.xml

Modified: continuum/branches/continuum-1.2.x/continuum-core/src/main/resources/org/apache/maven/continuum/notification/mail/templates/common.vm
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-core/src/main/resources/org/apache/maven/continuum/notification/mail/templates/common.vm?rev=703056&r1=703055&r2=703056&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-core/src/main/resources/org/apache/maven/continuum/notification/mail/templates/common.vm
(original)
+++ continuum/branches/continuum-1.2.x/continuum-core/src/main/resources/org/apache/maven/continuum/notification/mail/templates/common.vm
Wed Oct  8 21:57:18 2008
@@ -160,6 +160,11 @@
 ****************************************************************************
 Tests: $testResult.testCount
 Failures: $testResult.failureCount
+Errors: $testResult.errorCount
+#if( $testResult.testCount != 0)
+#set( $successRate = (($testResult.testCount - ( $testResult.failureCount + $testResult.errorCount))
* 100) / $testResult.testCount)
+Success Rate: $successRate
+#end
 Total time: $testResult.totalTime
 
 #end

Modified: continuum/branches/continuum-1.2.x/continuum-reports/src/main/java/org/apache/maven/continuum/reports/surefire/DefaultReportTestSuiteGenerator.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-reports/src/main/java/org/apache/maven/continuum/reports/surefire/DefaultReportTestSuiteGenerator.java?rev=703056&r1=703055&r2=703056&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-reports/src/main/java/org/apache/maven/continuum/reports/surefire/DefaultReportTestSuiteGenerator.java
(original)
+++ continuum/branches/continuum-1.2.x/continuum-reports/src/main/java/org/apache/maven/continuum/reports/surefire/DefaultReportTestSuiteGenerator.java
Wed Oct  8 21:57:18 2008
@@ -18,15 +18,6 @@
  */
 package org.apache.maven.continuum.reports.surefire;
 
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-import javax.xml.parsers.ParserConfigurationException;
-
 import org.apache.maven.continuum.configuration.ConfigurationException;
 import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
@@ -34,31 +25,37 @@
 import org.codehaus.plexus.util.DirectoryScanner;
 import org.xml.sax.SAXException;
 
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
 /**
  * @author <a href="mailto:olamy@apache.org">olamy</a>
- * @since 12 nov. 07
  * @version $Id$
- * 
- * @plexus.component 
- *    role="org.apache.maven.continuum.reports.surefire.ReportTestSuiteGenerator" role-hint="default"
+ * @plexus.component role="org.apache.maven.continuum.reports.surefire.ReportTestSuiteGenerator"
role-hint="default"
+ * @since 12 nov. 07
  */
 public class DefaultReportTestSuiteGenerator
     implements ReportTestSuiteGenerator, Initializable
 {
-    
+
     /**
      * @plexus.requirement
      */
     private ConfigurationService configurationService;
 
     private List<String> defaultIncludes;
-    
+
     private List<String> defaultexcludes;
 
     // -----------------------------
     //  Plexus Lifecycle
     // -----------------------------
-    
+
     public void initialize()
         throws InitializationException
     {
@@ -68,7 +65,7 @@
         defaultexcludes.add( "*.txt" );
     }
 
-    /** 
+    /**
      * @see org.apache.maven.continuum.reports.surefire.ReportTestSuiteGenerator#generateReports(java.io.File,
java.util.List, java.util.List)
      */
     public List<ReportTestSuite> generateReports( File directory, List<String>
includes, List<String> excludes )
@@ -83,7 +80,7 @@
             return Collections.EMPTY_LIST;
         }
         List<ReportTestSuite> reportTestSuites = new LinkedList<ReportTestSuite>();
-        String[] includesArray = null;
+        String[] includesArray;
         if ( includes == null )
         {
             includesArray = new String[0];
@@ -92,7 +89,7 @@
         {
             includesArray = includes.toArray( new String[includes.size()] );
         }
-        String[] excludesArray = null;
+        String[] excludesArray;
         if ( excludes == null )
         {
             excludesArray = new String[0];
@@ -103,20 +100,18 @@
         }
         String[] xmlReportFiles = getIncludedFiles( directory, includesArray, excludesArray
);
 
-        if (xmlReportFiles == null )
+        if ( xmlReportFiles == null )
         {
             return Collections.EMPTY_LIST;
         }
-        if (xmlReportFiles.length == 0)
+        if ( xmlReportFiles.length == 0 )
         {
             return Collections.EMPTY_LIST;
         }
-        for ( int index = 0; index < xmlReportFiles.length; index++ )
+        for ( String currentReport : xmlReportFiles )
         {
             ReportTestSuite testSuite = new ReportTestSuite();
 
-            String currentReport = xmlReportFiles[index];
-
             try
             {
                 testSuite.parse( directory + File.separator + currentReport );
@@ -139,7 +134,7 @@
         return reportTestSuites;
     }
 
-    /** 
+    /**
      * @see org.apache.maven.continuum.reports.surefire.ReportTestSuiteGenerator#generateReports(java.io.File)
      */
     public List<ReportTestSuite> generateReports( File directory )
@@ -147,10 +142,8 @@
     {
         return generateReports( directory, defaultIncludes, defaultexcludes );
     }
-    
-    
 
-    /** 
+    /**
      * @see org.apache.maven.continuum.reports.surefire.ReportTestSuiteGenerator#generateReports(int,
int)
      */
     public List<ReportTestSuite> generateReports( int buildId, int projectId )
@@ -166,16 +159,16 @@
             throw new ReportTestSuiteGeneratorException( e.getMessage(), e );
         }
     }
-    
-    /** 
-     * @see org.apache.maven.continuum.reports.surefire.ReportTestSuiteGenerator#generateTestResult(int,
int)
+
+    /**
+     * @see org.apache.maven.continuum.reports.surefire.ReportTestSuiteGenerator#generateReportTestResult(int,
int)
      */
     public ReportTestResult generateReportTestResult( int buildId, int projectId )
         throws ReportTestSuiteGeneratorException
     {
         List<ReportTestSuite> reportTestSuites = generateReports( buildId, projectId
);
         ReportTestResult reportTestResult = new ReportTestResult();
-        for (ReportTestSuite reportTestSuite : reportTestSuites)
+        for ( ReportTestSuite reportTestSuite : reportTestSuites )
         {
             reportTestResult.addReportTestSuite( reportTestSuite );
         }
@@ -196,5 +189,5 @@
 
         return scanner.getIncludedFiles();
     }
-    
+
 }

Modified: continuum/branches/continuum-1.2.x/continuum-reports/src/main/java/org/apache/maven/continuum/reports/surefire/ReportTestResult.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-reports/src/main/java/org/apache/maven/continuum/reports/surefire/ReportTestResult.java?rev=703056&r1=703055&r2=703056&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-reports/src/main/java/org/apache/maven/continuum/reports/surefire/ReportTestResult.java
(original)
+++ continuum/branches/continuum-1.2.x/continuum-reports/src/main/java/org/apache/maven/continuum/reports/surefire/ReportTestResult.java
Wed Oct  8 21:57:18 2008
@@ -23,32 +23,35 @@
 
 /**
  * @author <a href="mailto:olamy@apache.org">olamy</a>
- * @since 13 nov. 07
  * @version $Id$
+ * @since 13 nov. 07
  */
 public class ReportTestResult
 {
 
     private int testCount = 0;
-    
+
     private int failureCount = 0;
-    
+
+    private int errorCount = 0;
+
     private float totalTime = 0;
-    
+
     private List<ReportTestSuite> suiteResults;
 
-    public void addReportTestSuite(ReportTestSuite reportTestSuite)
+    public void addReportTestSuite( ReportTestSuite reportTestSuite )
     {
-        if (this.suiteResults == null)
+        if ( this.suiteResults == null )
         {
             this.suiteResults = new LinkedList<ReportTestSuite>();
         }
         this.suiteResults.add( reportTestSuite );
-        this.testCount = this.testCount + reportTestSuite.getNumberOfTests();
-        this.failureCount = this.failureCount + reportTestSuite.getNumberOfFailures();
-        this.totalTime = this.totalTime + reportTestSuite.getTimeElapsed();
+        this.testCount += reportTestSuite.getNumberOfTests();
+        this.failureCount += reportTestSuite.getNumberOfFailures();
+        this.errorCount += reportTestSuite.getNumberOfErrors();
+        this.totalTime += reportTestSuite.getTimeElapsed();
     }
-    
+
 
     public int getTestCount()
     {
@@ -70,6 +73,16 @@
         this.failureCount = failureCount;
     }
 
+    public int getErrorCount()
+    {
+        return errorCount;
+    }
+
+    public void setErrorCount( int errorCount )
+    {
+        this.errorCount = errorCount;
+    }
+
     public List<ReportTestSuite> getSuiteResults()
     {
         return suiteResults;
@@ -79,7 +92,7 @@
     {
         this.suiteResults = suiteResults;
     }
-    
+
     public float getTotalTime()
     {
         return totalTime;
@@ -88,6 +101,6 @@
     public void setTotalTime( float totalTime )
     {
         this.totalTime = totalTime;
-    }    
-    
+    }
+
 }

Modified: continuum/branches/continuum-1.2.x/continuum-reports/src/main/java/org/apache/maven/continuum/reports/surefire/ReportTestSuite.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-reports/src/main/java/org/apache/maven/continuum/reports/surefire/ReportTestSuite.java?rev=703056&r1=703055&r2=703056&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-reports/src/main/java/org/apache/maven/continuum/reports/surefire/ReportTestSuite.java
(original)
+++ continuum/branches/continuum-1.2.x/continuum-reports/src/main/java/org/apache/maven/continuum/reports/surefire/ReportTestSuite.java
Wed Oct  8 21:57:18 2008
@@ -18,6 +18,13 @@
  */
 package org.apache.maven.continuum.reports.surefire;
 
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
 import java.io.File;
 import java.io.IOException;
 import java.text.NumberFormat;
@@ -26,18 +33,10 @@
 import java.util.LinkedList;
 import java.util.List;
 
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
 /**
  * @author <a href="mailto:olamy@apache.org">olamy</a>
- * @since 12 nov. 07
  * @version $Id$
+ * @since 12 nov. 07
  */
 public class ReportTestSuite
     extends DefaultHandler
@@ -66,7 +65,7 @@
     private StringBuffer currentElement;
 
     private ReportTestCase testCase;
-    
+
     private List<ReportFailure> reportFailures;
 
 
@@ -178,12 +177,14 @@
         else if ( "failure".equals( qName ) )
         {
             testCase.setFailureDetails( currentElement.toString() );
-            this.addReportFailure( new ReportFailure( testCase.getFailureType(), testCase.getFailureDetails(),
testCase.getName() ) );
+            this.addReportFailure(
+                new ReportFailure( testCase.getFailureType(), testCase.getFailureDetails(),
testCase.getName() ) );
         }
         else if ( "error".equals( qName ) )
         {
-            this.addReportFailure( new ReportFailure( testCase.getFailureType(), testCase.getFailureDetails(),
testCase.getName() ) );
             testCase.setFailureDetails( currentElement.toString() );
+            this.addReportFailure(
+                new ReportFailure( testCase.getFailureType(), testCase.getFailureDetails(),
testCase.getName() ) );
         }
     }
 
@@ -305,8 +306,8 @@
     {
         this.testCases = Collections.unmodifiableList( testCases );
     }
-    
-    @SuppressWarnings ("unchecked")
+
+    @SuppressWarnings("unchecked")
     public List<ReportFailure> getReportFailures()
     {
         return reportFailures == null ? Collections.EMPTY_LIST : reportFailures;

Modified: continuum/branches/continuum-1.2.x/continuum-reports/src/test/java/org/apache/maven/continuum/reports/surefire/DefaultReportTestSuiteGeneratorTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-reports/src/test/java/org/apache/maven/continuum/reports/surefire/DefaultReportTestSuiteGeneratorTest.java?rev=703056&r1=703055&r2=703056&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-reports/src/test/java/org/apache/maven/continuum/reports/surefire/DefaultReportTestSuiteGeneratorTest.java
(original)
+++ continuum/branches/continuum-1.2.x/continuum-reports/src/test/java/org/apache/maven/continuum/reports/surefire/DefaultReportTestSuiteGeneratorTest.java
Wed Oct  8 21:57:18 2008
@@ -18,15 +18,15 @@
  */
 package org.apache.maven.continuum.reports.surefire;
 
+import org.codehaus.plexus.spring.PlexusInSpringTestCase;
+
 import java.io.File;
 import java.util.List;
 
-import org.codehaus.plexus.spring.PlexusInSpringTestCase;
-
 /**
  * @author <a href="mailto:olamy@apache.org">olamy</a>
- * @since 12 nov. 07
  * @version $Id$
+ * @since 12 nov. 07
  */
 public class DefaultReportTestSuiteGeneratorTest
     extends PlexusInSpringTestCase
@@ -34,8 +34,8 @@
 
     private File getReportsDirectory( String pathDir )
     {
-        return new File( getBasedir() + File.separatorChar + "src" + File.separatorChar +
"test" + File.separatorChar
-            + "resources" + File.separatorChar + pathDir );
+        return new File( getBasedir() + File.separatorChar + "src" + File.separatorChar +
"test" + File.separatorChar +
+            "resources" + File.separatorChar + pathDir );
     }
 
     public void testSimpleFile()
@@ -43,8 +43,8 @@
     {
         File testDirectory = getReportsDirectory( "simplereport" );
 
-        ReportTestSuiteGenerator generator = (ReportTestSuiteGenerator) lookup( ReportTestSuiteGenerator.class,
-                                                                                "default"
);
+        ReportTestSuiteGenerator generator =
+            (ReportTestSuiteGenerator) lookup( ReportTestSuiteGenerator.class, "default"
);
 
         List<ReportTestSuite> reports = generator.generateReports( testDirectory );
         assertEquals( 1, reports.size() );
@@ -59,16 +59,16 @@
     public void testContinuumCore()
         throws Exception
     {
-        ReportTestSuiteGenerator generator = (ReportTestSuiteGenerator) lookup( ReportTestSuiteGenerator.class,
-                                                                                "default"
);
+        ReportTestSuiteGenerator generator =
+            (ReportTestSuiteGenerator) lookup( ReportTestSuiteGenerator.class, "default"
);
         List<ReportTestSuite> reports = generator.generateReports( 1, 1 );
 
         assertEquals( 18, reports.size() );
 
         for ( ReportTestSuite report : reports )
         {
-            if ( report.getName().equals( "MailContinuumNotifierTest" )
-                && report.getPackageName().equals( "org.apache.maven.continuum.notification.mail"
) )
+            if ( report.getName().equals( "MailContinuumNotifierTest" ) &&
+                report.getPackageName().equals( "org.apache.maven.continuum.notification.mail"
) )
             {
                 assertEquals( 1, report.getNumberOfFailures() );
                 // don't test this because can plate forme dependant
@@ -88,15 +88,16 @@
 
         }
     }
-    
+
     public void testgenerateReportTestResult()
-    throws Exception
+        throws Exception
     {
-        ReportTestSuiteGenerator generator = (ReportTestSuiteGenerator) lookup( ReportTestSuiteGenerator.class,
-                                                                                "default"
);
+        ReportTestSuiteGenerator generator =
+            (ReportTestSuiteGenerator) lookup( ReportTestSuiteGenerator.class, "default"
);
         ReportTestResult reportTestResult = generator.generateReportTestResult( 1, 1 );
         assertEquals( 18, reportTestResult.getSuiteResults().size() );
         assertEquals( 1, reportTestResult.getFailureCount() );
-        assertEquals( 61, reportTestResult.getTestCount() );
+        assertEquals( 62, reportTestResult.getTestCount() );
+        assertEquals( 1, reportTestResult.getErrorCount() );
     }
 }

Modified: continuum/branches/continuum-1.2.x/continuum-reports/src/test/resources/continuum-core/TEST-org.apache.maven.continuum.scm.ContinuumScmTest.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.2.x/continuum-reports/src/test/resources/continuum-core/TEST-org.apache.maven.continuum.scm.ContinuumScmTest.xml?rev=703056&r1=703055&r2=703056&view=diff
==============================================================================
--- continuum/branches/continuum-1.2.x/continuum-reports/src/test/resources/continuum-core/TEST-org.apache.maven.continuum.scm.ContinuumScmTest.xml
(original)
+++ continuum/branches/continuum-1.2.x/continuum-reports/src/test/resources/continuum-core/TEST-org.apache.maven.continuum.scm.ContinuumScmTest.xml
Wed Oct  8 21:57:18 2008
@@ -1,5 +1,5 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<testsuite errors="0" skipped="0" tests="1" time="2.016" failures="0" name="org.apache.maven.continuum.scm.ContinuumScmTest">
+<?xml version="1.0" encoding="UTF-8" ?>
+<testsuite errors="1" skipped="0" tests="2" time="2.016" failures="0" name="org.apache.maven.continuum.scm.ContinuumScmTest">
   <properties>
     <property value="sa" name="javax.jdo.option.ConnectionUserName"/>
     <property value="Java(TM) 2 Runtime Environment, Standard Edition" name="java.runtime.name"/>
@@ -21,7 +21,7 @@
     <property value="c:\jdk1.5.0_08\jre\lib\endorsed" name="java.endorsed.dirs"/>
     <property value="x86" name="os.arch"/>
     <property value="c:\DOCUME~1\olamy\LOCALS~1\Temp\" name="java.io.tmpdir"/>
-    <property value="
+    <property value="
 " name="line.separator"/>
     <property value="Sun Microsystems Inc." name="java.vm.specification.vendor"/>
     <property value="" name="user.variant"/>
@@ -67,4 +67,5 @@
     <property value="pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86" name="sun.cpu.isalist"/>
   </properties>
   <testcase time="2" name="testBasic"/>
+  <testcase time="2" name="testBasic2"/>
 </testsuite>
\ No newline at end of file



Mime
View raw message