maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krosenv...@apache.org
Subject svn commit: r954518 - in /maven/surefire/trunk: surefire-api/src/main/java/org/apache/maven/surefire/ surefire-api/src/main/java/org/apache/maven/surefire/report/ surefire-api/src/main/java/org/apache/maven/surefire/suite/ surefire-providers/surefire-j...
Date Mon, 14 Jun 2010 15:36:44 GMT
Author: krosenvold
Date: Mon Jun 14 15:36:43 2010
New Revision: 954518

URL: http://svn.apache.org/viewvc?rev=954518&view=rev
Log:
o Extracted ReporterManagerFactory, simple refactoring with no logic change

Extracted construction of ReporterManager into separate factory that is sent to the providers,
enabling the providers to potentially have finer grained control over instance creation
wrt ReporterManager. This is in preparation for a future fix where parallel surefire providers
can have non-blocking reporting.

Added:
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory.java
  (with props)
Modified:
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractConsoleReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/AbstractDirectoryTestSuite.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/SurefireTestSuite.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreDirectoryTestSuite.java
    maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java
    maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGXmlTestSuite.java

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java?rev=954518&r1=954517&r2=954518&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java
(original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java
Mon Jun 14 15:36:43 2010
@@ -22,6 +22,7 @@ package org.apache.maven.surefire;
 import org.apache.maven.surefire.report.Reporter;
 import org.apache.maven.surefire.report.ReporterException;
 import org.apache.maven.surefire.report.ReporterManager;
+import org.apache.maven.surefire.report.ReporterManagerFactory;
 import org.apache.maven.surefire.report.RunStatistics;
 import org.apache.maven.surefire.suite.SurefireTestSuite;
 import org.apache.maven.surefire.testset.TestSetFailedException;
@@ -80,10 +81,10 @@ public class Surefire
                     Boolean failIfNoTests )
         throws ReporterException, TestSetFailedException
     {
-        RunStatistics runStatistics = new RunStatistics();
-        ReporterManager reporterManager =
-            new ReporterManager( instantiateReports( reportDefinitions, surefireClassLoader
) , runStatistics);
+        ReporterManagerFactory reporterManagerFactory =
+            new ReporterManagerFactory( reportDefinitions, surefireClassLoader);
 
+        RunStatistics runStatistics = reporterManagerFactory.getGlobalRunStatistics();
         if ( results != null )
         {
             runStatistics.initResultsFromProperties( results );
@@ -99,18 +100,16 @@ public class Surefire
             totalTests += testCount;
         }
 
-        reporterManager.runStarting();
-
         if ( totalTests == 0 )
         {
-            reporterManager.writeMessage( "There are no tests to run." );
+            reporterManagerFactory.createReporterManager().writeMessage( "There are no tests
to run." );
         }
         else
         {
-            suite.execute( testSetName, reporterManager, testsClassLoader );
+            suite.execute( testSetName, reporterManagerFactory, testsClassLoader );
         }
 
-        reporterManager.runCompleted();
+        reporterManagerFactory.close();
 
         if ( results != null )
         {
@@ -141,9 +140,10 @@ public class Surefire
                         ClassLoader testsClassLoader, Boolean failIfNoTests )
         throws ReporterException, TestSetFailedException
     {
-        RunStatistics runStatistics = new RunStatistics();
-        ReporterManager reporterManager =
-            new ReporterManager( instantiateReports( reportDefinitions, surefireClassLoader
), runStatistics );
+        ReporterManagerFactory reporterManagerFactory =
+            new ReporterManagerFactory( reportDefinitions, surefireClassLoader);
+
+        RunStatistics runStatistics = reporterManagerFactory.getGlobalRunStatistics();
 
         List suites = new ArrayList();
 
@@ -162,22 +162,20 @@ public class Surefire
             }
         }
 
-        reporterManager.runStarting();
-
         if ( totalTests == 0 )
         {
-            reporterManager.writeMessage( "There are no tests to run." );
+            reporterManagerFactory.createReporterManager().writeMessage( "There are no tests
to run." );
         }
         else
         {
             for ( Iterator i = suites.iterator(); i.hasNext(); )
             {
                 SurefireTestSuite suite = (SurefireTestSuite) i.next();
-                suite.execute( reporterManager, testsClassLoader );
+                suite.execute( reporterManagerFactory, testsClassLoader );
             }
         }
 
-        reporterManager.runCompleted();
+        reporterManagerFactory.close();
         if ( failIfNoTests.booleanValue() )
         {
             if ( runStatistics.getCompletedCount() == 0 )

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractConsoleReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractConsoleReporter.java?rev=954518&r1=954517&r2=954518&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractConsoleReporter.java
(original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractConsoleReporter.java
Mon Jun 14 15:36:43 2010
@@ -21,6 +21,7 @@ package org.apache.maven.surefire.report
 
 import java.io.BufferedOutputStream;
 import java.io.OutputStreamWriter;
+import java.io.PrintStream;
 import java.io.PrintWriter;
 
 /**
@@ -39,10 +40,12 @@ public abstract class AbstractConsoleRep
 
     protected static final int BUFFER_SIZE = 4096;
 
+    private static final PrintStream originalSystemOut = System.out;
+
     protected AbstractConsoleReporter( String format, Boolean trimStackTrace )
     {
         // TODO: use logger
-        super( new PrintWriter( new OutputStreamWriter( new BufferedOutputStream( System.out,
BUFFER_SIZE ) ) ), format,
+        super( new PrintWriter( new OutputStreamWriter( new BufferedOutputStream( originalSystemOut,
BUFFER_SIZE ) ) ), format,
                trimStackTrace );
     }
 

Added: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory.java?rev=954518&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory.java
(added)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory.java
Mon Jun 14 15:36:43 2010
@@ -0,0 +1,186 @@
+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 org.apache.maven.surefire.testset.TestSetFailedException;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Creates ReporterManager instances for the providers.
+ * <p/>
+ * A ReporterManager and the underlying reporters are stateful objects. For safe concurrent
usage
+ * of the reporting infrastructure, each thread needs its own instance.
+ * <p/>
+ * This factory also ensures that runStarting/runCompleted is called on the FIRST reporterManger
that
+ * is allocated, but none of the subsequent managers.
+ *
+ * @author Jason van Zyl
+ * @author Kristian Rosenvold (extracted factory)
+ */
+public class ReporterManagerFactory
+{
+    private final List reportDefinitions;
+
+    private final ClassLoader surefireClassLoader;
+
+    private final RunStatistics globalRunStatistics = new RunStatistics();
+
+    private ReporterManager first;
+
+    private final Object lock = new Object();
+
+
+    public ReporterManagerFactory( List reportDefinitions, ClassLoader surefireClassLoader
)
+    {
+        this.reportDefinitions = reportDefinitions;
+        this.surefireClassLoader = surefireClassLoader;
+    }
+
+
+    public RunStatistics getGlobalRunStatistics()
+    {
+        return globalRunStatistics;
+    }
+
+    public ReporterManager createReporterManager()
+        throws TestSetFailedException
+    {
+        final List reports = instantiateReports( reportDefinitions, surefireClassLoader );
+        final ReporterManager reporterManager = new ReporterManager( reports, globalRunStatistics
);
+        if ( first == null )
+        {
+            synchronized ( lock )
+            {
+                if ( first == null )
+                {
+                    first = reporterManager;
+                    reporterManager.runStarting();
+                }
+            }
+        }
+        return reporterManager;
+    }
+
+    public void close()
+    {
+        synchronized ( lock )
+        {
+            if ( first != null )
+            {
+                first.runCompleted();
+            }
+        }
+    }
+
+
+    private List instantiateReports( List reportDefinitions, ClassLoader classLoader )
+        throws TestSetFailedException
+    {
+        List reports = new ArrayList();
+
+        for ( Iterator i = reportDefinitions.iterator(); i.hasNext(); )
+        {
+            Object[] definition = (Object[]) i.next();
+
+            String className = (String) definition[0];
+            Object[] params = (Object[]) definition[1];
+
+            Reporter report = instantiateReport( className, params, classLoader );
+
+            reports.add( report );
+        }
+
+        return reports;
+    }
+
+    private static Reporter instantiateReport( String className, Object[] params, ClassLoader
classLoader )
+        throws TestSetFailedException
+    {
+        try
+        {
+            return (Reporter) instantiateObject( className, params, classLoader );
+        }
+        catch ( ClassNotFoundException e )
+        {
+            throw new TestSetFailedException( "Unable to find class to create report '" +
className + "'", e );
+        }
+        catch ( NoSuchMethodException e )
+        {
+            throw new TestSetFailedException(
+                "Unable to find appropriate constructor to create report: " + e.getMessage(),
e );
+        }
+    }
+
+    private static Object instantiateObject( String className, Object[] params, ClassLoader
classLoader )
+        throws TestSetFailedException, ClassNotFoundException, NoSuchMethodException
+    {
+        Class clazz = classLoader.loadClass( className );
+
+        Object object;
+        try
+        {
+            if ( params != null )
+            {
+                Class[] paramTypes = new Class[params.length];
+
+                for ( int j = 0; j < params.length; j++ )
+                {
+                    if ( params[j] == null )
+                    {
+                        paramTypes[j] = String.class;
+                    }
+                    else
+                    {
+                        paramTypes[j] = params[j].getClass();
+                    }
+                }
+
+                Constructor constructor = clazz.getConstructor( paramTypes );
+
+                object = constructor.newInstance( params );
+            }
+            else
+            {
+                object = clazz.newInstance();
+            }
+        }
+        catch ( IllegalAccessException e )
+        {
+            throw new TestSetFailedException( "Unable to instantiate object: " + e.getMessage(),
e );
+        }
+        catch ( InvocationTargetException e )
+        {
+            throw new TestSetFailedException( e.getTargetException().getMessage(), e.getTargetException()
);
+        }
+        catch ( InstantiationException e )
+        {
+            throw new TestSetFailedException( "Unable to instantiate object: " + e.getMessage(),
e );
+        }
+        return object;
+    }
+
+
+}

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

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/AbstractDirectoryTestSuite.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/AbstractDirectoryTestSuite.java?rev=954518&r1=954517&r2=954518&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/AbstractDirectoryTestSuite.java
(original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/AbstractDirectoryTestSuite.java
Mon Jun 14 15:36:43 2010
@@ -20,6 +20,7 @@ package org.apache.maven.surefire.suite;
  */
 
 import org.apache.maven.surefire.Surefire;
+import org.apache.maven.surefire.report.ReporterManagerFactory;
 import org.apache.maven.surefire.util.SurefireDirectoryScanner;
 import org.apache.maven.surefire.report.ReportEntry;
 import org.apache.maven.surefire.report.ReporterException;
@@ -88,7 +89,7 @@ public abstract class AbstractDirectoryT
     protected abstract SurefireTestSet createTestSet( Class testClass, ClassLoader classLoader
)
         throws TestSetFailedException;
 
-    public void execute( ReporterManager reporterManager, ClassLoader classLoader )
+    public void execute( ReporterManagerFactory reporterManagerFactory, ClassLoader classLoader
)
         throws ReporterException, TestSetFailedException
     {
         if ( testSets == null )
@@ -99,13 +100,17 @@ public abstract class AbstractDirectoryT
         {
             SurefireTestSet testSet = (SurefireTestSet) i.next();
 
-            executeTestSet( testSet, reporterManager, classLoader );
+            executeTestSet( testSet, reporterManagerFactory, classLoader );
         }
     }
 
-    private void executeTestSet( SurefireTestSet testSet, ReporterManager reporterManager,
ClassLoader classLoader )
+    private void executeTestSet( SurefireTestSet testSet, ReporterManagerFactory reporterManagerFactory,
+                                 ClassLoader classLoader )
         throws ReporterException, TestSetFailedException
     {
+
+        ReporterManager reporterManager = reporterManagerFactory.createReporterManager();
+
         String rawString = bundle.getString( "testSetStarting" );
 
         ReportEntry report = new ReportEntry( this.getClass().getName(), testSet.getName(),
rawString );
@@ -123,7 +128,7 @@ public abstract class AbstractDirectoryT
         reporterManager.reset();
     }
 
-    public void execute( String testSetName, ReporterManager reporterManager, ClassLoader
classLoader )
+    public void execute( String testSetName, ReporterManagerFactory reporterManagerFactory,
ClassLoader classLoader )
         throws ReporterException, TestSetFailedException
     {
         if ( testSets == null )
@@ -137,7 +142,7 @@ public abstract class AbstractDirectoryT
             throw new TestSetFailedException( "Unable to find test set '" + testSetName +
"' in suite" );
         }
 
-        executeTestSet( testSet, reporterManager, classLoader );
+        executeTestSet( testSet, reporterManagerFactory, classLoader );
     }
 
     public int getNumTests()

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/SurefireTestSuite.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/SurefireTestSuite.java?rev=954518&r1=954517&r2=954518&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/SurefireTestSuite.java
(original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/SurefireTestSuite.java
Mon Jun 14 15:36:43 2010
@@ -20,7 +20,7 @@ package org.apache.maven.surefire.suite;
  */
 
 import org.apache.maven.surefire.report.ReporterException;
-import org.apache.maven.surefire.report.ReporterManager;
+import org.apache.maven.surefire.report.ReporterManagerFactory;
 import org.apache.maven.surefire.testset.TestSetFailedException;
 
 import java.util.Map;
@@ -32,10 +32,10 @@ import java.util.Map;
  */
 public interface SurefireTestSuite
 {
-    void execute( ReporterManager reporterManager, ClassLoader classLoader )
+    void execute( ReporterManagerFactory reporterManagerFactory, ClassLoader classLoader
)
         throws ReporterException, TestSetFailedException;
 
-    void execute( String testSetName, ReporterManager reporterManager, ClassLoader classLoader
)
+    void execute( String testSetName, ReporterManagerFactory reporterManagerFactory, ClassLoader
classLoader )
         throws ReporterException, TestSetFailedException;
 
     int getNumTests();

Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreDirectoryTestSuite.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreDirectoryTestSuite.java?rev=954518&r1=954517&r2=954518&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreDirectoryTestSuite.java
(original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreDirectoryTestSuite.java
Mon Jun 14 15:36:43 2010
@@ -21,6 +21,7 @@ package org.apache.maven.surefire.junitc
 
 import org.apache.maven.surefire.report.ReporterException;
 import org.apache.maven.surefire.report.ReporterManager;
+import org.apache.maven.surefire.report.ReporterManagerFactory;
 import org.apache.maven.surefire.suite.SurefireTestSuite;
 import org.apache.maven.surefire.testset.TestSetFailedException;
 import org.apache.maven.surefire.util.SurefireDirectoryScanner;
@@ -55,7 +56,7 @@ public class JUnitCoreDirectoryTestSuite
     }
 
 
-    public void execute( ReporterManager reporterManager, ClassLoader classLoader )
+    public void execute( ReporterManagerFactory reporterManagerFactory, ClassLoader classLoader
)
         throws ReporterException, TestSetFailedException
     {
         if ( testsToRun == null )
@@ -63,10 +64,11 @@ public class JUnitCoreDirectoryTestSuite
             throw new IllegalStateException( "You must call locateTestSets before calling
execute" );
         }
 
+        final ReporterManager reporterManager = reporterManagerFactory.createReporterManager();
         JUnitCoreTestSet.execute( testsToRun.getLocatedClasses(), reporterManager, jUnitCoreParameters
);
     }
 
-    public void execute( String testSetName, ReporterManager reporterManager, ClassLoader
classLoader )
+    public void execute( String testSetName, ReporterManagerFactory reporterManagerFactory,
ClassLoader classLoader )
         throws ReporterException, TestSetFailedException
     {
         if ( testsToRun == null )
@@ -75,11 +77,12 @@ public class JUnitCoreDirectoryTestSuite
         }
         JUnitCoreTestSet testSet = testsToRun.getTestSet( testSetName );
 
+
         if ( testSet == null )
         {
             throw new TestSetFailedException( "Unable to find test set '" + testSetName +
"' in suite" );
         }
-        testSet.execute( reporterManager, jUnitCoreParameters );
+        testSet.execute( reporterManagerFactory.createReporterManager(), jUnitCoreParameters
);
     }
 
     public Map locateTestSets( ClassLoader classLoader )

Modified: maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java?rev=954518&r1=954517&r2=954518&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java
(original)
+++ maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java
Mon Jun 14 15:36:43 2010
@@ -32,6 +32,7 @@ import org.apache.maven.artifact.version
 import org.apache.maven.surefire.report.ReportEntry;
 import org.apache.maven.surefire.report.ReporterException;
 import org.apache.maven.surefire.report.ReporterManager;
+import org.apache.maven.surefire.report.ReporterManagerFactory;
 import org.apache.maven.surefire.suite.AbstractDirectoryTestSuite;
 import org.apache.maven.surefire.testset.SurefireTestSet;
 import org.apache.maven.surefire.testset.TestSetFailedException;
@@ -83,7 +84,7 @@ public class TestNGDirectoryTestSuite
     }
 
     // single class test
-    public void execute( String testSetName, ReporterManager reporterManager, ClassLoader
classLoader )
+    public void execute( String testSetName, ReporterManagerFactory reporterManagerFactory,
ClassLoader classLoader )
         throws ReporterException, TestSetFailedException
     {
         if ( testSets == null )
@@ -96,7 +97,8 @@ public class TestNGDirectoryTestSuite
         {
             throw new TestSetFailedException( "Unable to find test set '" + testSetName +
"' in suite" );
         }
-        
+
+        ReporterManager reporterManager = reporterManagerFactory.createReporterManager();
         startTestSuite( reporterManager, this );
 
         TestNGExecutor.run( new Class[]{testSet.getTestClass()}, this.testSourceDirectory,
this.options, this.version,
@@ -105,7 +107,7 @@ public class TestNGDirectoryTestSuite
         finishTestSuite( reporterManager, this );
     }
 
-    public void execute( ReporterManager reporterManager, ClassLoader classLoader )
+    public void execute( ReporterManagerFactory reporterManagerFactory, ClassLoader classLoader
)
         throws ReporterException, TestSetFailedException
     {
         if ( testSets == null )
@@ -133,7 +135,8 @@ public class TestNGDirectoryTestSuite
             testNgReportsDirectory = new File( reportsDirectory, "testng-native-results");
             junitReportsDirectory = new File( reportsDirectory, "testng-junit-results");
         }
-        
+
+        ReporterManager reporterManager = reporterManagerFactory.createReporterManager();
         startTestSuite( reporterManager, this );
         
         Class[] testClasses = (Class[]) testNgTestClasses.toArray( new Class[0] );

Modified: maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGXmlTestSuite.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGXmlTestSuite.java?rev=954518&r1=954517&r2=954518&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGXmlTestSuite.java
(original)
+++ maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGXmlTestSuite.java
Mon Jun 14 15:36:43 2010
@@ -32,6 +32,7 @@ import org.apache.maven.artifact.version
 import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
 import org.apache.maven.surefire.report.ReporterException;
 import org.apache.maven.surefire.report.ReporterManager;
+import org.apache.maven.surefire.report.ReporterManagerFactory;
 import org.apache.maven.surefire.suite.SurefireTestSuite;
 import org.apache.maven.surefire.testset.TestSetFailedException;
 
@@ -81,20 +82,21 @@ public class TestNGXmlTestSuite
         this.reportsDirectory = reportsDirectory;
     }
 
-    public void execute( ReporterManager reporterManager, ClassLoader classLoader )
+    public void execute( ReporterManagerFactory reporterManagerFactory, ClassLoader classLoader
)
         throws ReporterException, TestSetFailedException
     {
         if ( testSets == null )
         {
             throw new IllegalStateException( "You must call locateTestSets before calling
execute" );
         }
+        ReporterManager reporterManager = reporterManagerFactory.createReporterManager();
         TestNGDirectoryTestSuite.startTestSuite( reporterManager, this );
         TestNGExecutor.run( this.suiteFilePaths, this.testSourceDirectory, this.options,
this.version, 
                             this.classifier, reporterManager, this, reportsDirectory );
         TestNGDirectoryTestSuite.finishTestSuite( reporterManager, this );
     }
 
-    public void execute( String testSetName, ReporterManager reporterManager, ClassLoader
classLoader )
+    public void execute( String testSetName, ReporterManagerFactory reporterManagerFactory,
ClassLoader classLoader )
         throws TestSetFailedException
     {
         throw new TestSetFailedException( "Cannot run individual test when suite files are
specified" );



Mime
View raw message