You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2015/12/12 22:53:30 UTC

[2/2] maven-surefire git commit: [SUREFIRE-1208] Start stream capture before loading tests

[SUREFIRE-1208] Start stream capture before loading tests


Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/9cefb7ba
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/9cefb7ba
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/9cefb7ba

Branch: refs/heads/master
Commit: 9cefb7ba43b2550f3ede2952b47d079463c33328
Parents: b2bf3b0
Author: Tibor17 <ti...@lycos.com>
Authored: Sat Dec 12 22:47:39 2015 +0100
Committer: Tibor17 <ti...@lycos.com>
Committed: Sat Dec 12 22:47:39 2015 +0100

----------------------------------------------------------------------
 .../maven/surefire/junit4/JUnit4Provider.java   |  40 +++---
 .../surefire/junitcore/JUnitCoreProvider.java   |  39 +++---
 .../ConfigurationAwareTestNGReporter.java       |   2 +-
 .../testng/TestNGDirectoryTestSuite.java        | 124 ++++---------------
 .../maven/surefire/testng/TestNGExecutor.java   |  28 ++---
 .../maven/surefire/testng/TestNGProvider.java   |  32 ++---
 .../surefire/testng/TestNGXmlTestSuite.java     |  49 +++-----
 .../maven/surefire/testng/TestNgTestSuite.java  |  39 ------
 8 files changed, 106 insertions(+), 247 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/9cefb7ba/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java b/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
index 0528574..6d42b40 100644
--- a/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
+++ b/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
@@ -121,22 +121,6 @@ public class JUnit4Provider
             throw new TestSetFailedException( "don't enable parameters rerunFailingTestsCount, skipAfterFailureCount" );
         }
 
-        if ( testsToRun == null )
-        {
-            if ( forkTestSet instanceof TestsToRun )
-            {
-                testsToRun = (TestsToRun) forkTestSet;
-            }
-            else if ( forkTestSet instanceof Class )
-            {
-                testsToRun = fromClass( (Class<?>) forkTestSet );
-            }
-            else
-            {
-                testsToRun = scanClassPath();
-            }
-        }
-
         upgradeCheck();
 
         ReporterFactory reporterFactory = providerParameters.getReporterFactory();
@@ -144,10 +128,15 @@ public class JUnit4Provider
         RunResult runResult;
         try
         {
-
             RunListener reporter = reporterFactory.createReporter();
 
             startCapture( (ConsoleOutputReceiver) reporter );
+            // startCapture() called in prior to setTestsToRun()
+
+            if ( testsToRun == null )
+            {
+                setTestsToRun( forkTestSet );
+            }
 
             Notifier notifier = new Notifier( new JUnit4RunListener( reporter ), getSkipAfterFailureCount() );
             if ( isFailFast() )
@@ -200,6 +189,23 @@ public class JUnit4Provider
         return runResult;
     }
 
+    private void setTestsToRun( Object forkTestSet )
+        throws TestSetFailedException
+    {
+        if ( forkTestSet instanceof TestsToRun )
+        {
+            testsToRun = (TestsToRun) forkTestSet;
+        }
+        else if ( forkTestSet instanceof Class )
+        {
+            testsToRun = fromClass( (Class<?>) forkTestSet );
+        }
+        else
+        {
+            testsToRun = scanClassPath();
+        }
+    }
+
     private boolean isRerunFailingTests()
     {
         return rerunFailingTestsCount > 0;

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/9cefb7ba/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
index aa0c1a7..72d0b13 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
@@ -133,26 +133,15 @@ public class JUnitCoreProvider
 
         Filter filter = jUnit48Reflector.isJUnit48Available() ? createJUnit48Filter() : null;
 
+        Notifier notifier =
+            new Notifier( createRunListener( reporterFactory, consoleLogger ), getSkipAfterFailureCount() );
+        // startCapture() called in createRunListener() in prior to setTestsToRun()
+
         if ( testsToRun == null )
         {
-            if ( forkTestSet instanceof TestsToRun )
-            {
-                testsToRun = (TestsToRun) forkTestSet;
-            }
-            else if ( forkTestSet instanceof Class )
-            {
-                Class<?> theClass = (Class<?>) forkTestSet;
-                testsToRun = fromClass( theClass );
-            }
-            else
-            {
-                testsToRun = scanClassPath();
-            }
+            setTestsToRun( forkTestSet );
         }
 
-        Notifier notifier =
-            new Notifier( createRunListener( reporterFactory, consoleLogger ), getSkipAfterFailureCount() );
-
         // Add test failure listener
         JUnitTestFailureListener testFailureListener = new JUnitTestFailureListener();
         notifier.addListener( testFailureListener );
@@ -202,6 +191,24 @@ public class JUnitCoreProvider
         return runResult;
     }
 
+    private void setTestsToRun( Object forkTestSet )
+        throws TestSetFailedException
+    {
+        if ( forkTestSet instanceof TestsToRun )
+        {
+            testsToRun = (TestsToRun) forkTestSet;
+        }
+        else if ( forkTestSet instanceof Class )
+        {
+            Class<?> theClass = (Class<?>) forkTestSet;
+            testsToRun = fromClass( theClass );
+        }
+        else
+        {
+            testsToRun = scanClassPath();
+        }
+    }
+
     private boolean isRerunFailingTests()
     {
         return rerunFailingTestsCount > 0;

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/9cefb7ba/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/ConfigurationAwareTestNGReporter.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/ConfigurationAwareTestNGReporter.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/ConfigurationAwareTestNGReporter.java
index 6da1405..956a9d9 100644
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/ConfigurationAwareTestNGReporter.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/ConfigurationAwareTestNGReporter.java
@@ -35,7 +35,7 @@ public class ConfigurationAwareTestNGReporter
     implements IResultListener
 {
 
-    public ConfigurationAwareTestNGReporter( RunListener reportManager, TestNgTestSuite source )
+    public ConfigurationAwareTestNGReporter( RunListener reportManager )
     {
         super( reportManager );
     }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/9cefb7ba/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java
index 662ed5a..312e6c6 100644
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java
@@ -23,26 +23,17 @@ import java.io.File;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.SortedMap;
-import java.util.TreeMap;
 
-import org.apache.maven.surefire.NonAbstractClassFilter;
 import org.apache.maven.surefire.cli.CommandLineOption;
-import org.apache.maven.surefire.report.ConsoleOutputCapture;
-import org.apache.maven.surefire.report.ConsoleOutputReceiver;
 import org.apache.maven.surefire.report.ReportEntry;
 import org.apache.maven.surefire.report.ReporterException;
-import org.apache.maven.surefire.report.ReporterFactory;
 import org.apache.maven.surefire.report.RunListener;
 import org.apache.maven.surefire.report.SimpleReportEntry;
 import org.apache.maven.surefire.testset.TestListResolver;
 import org.apache.maven.surefire.testset.TestSetFailedException;
-import org.apache.maven.surefire.util.RunOrderCalculator;
-import org.apache.maven.surefire.util.ScanResult;
 import org.apache.maven.surefire.util.TestsToRun;
 
 /**
@@ -51,8 +42,7 @@ import org.apache.maven.surefire.util.TestsToRun;
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
  * @author <a href='mailto:the[dot]mindstorm[at]gmail[dot]com'>Alex Popescu</a>
  */
-public class TestNGDirectoryTestSuite
-    implements TestNgTestSuite
+final class TestNGDirectoryTestSuite
 {
 
     private final Map<String, String> options;
@@ -63,14 +53,8 @@ public class TestNGDirectoryTestSuite
 
     private final File reportsDirectory;
 
-    private SortedMap<String, TestNGTestSet> testSets;
-
-    private final ScanResult scanResult;
-
     private final TestListResolver methodFilter;
 
-    private final RunOrderCalculator runOrderCalculator;
-
     private final Class<?> junitTestClass;
 
     private final Class<? extends Annotation> junitRunWithAnnotation;
@@ -81,16 +65,13 @@ public class TestNGDirectoryTestSuite
 
     private final int skipAfterFailureCount;
 
-    public TestNGDirectoryTestSuite( String testSourceDirectory, Map<String, String> confOptions, File reportsDirectory,
-                                     TestListResolver methodFilter, RunOrderCalculator runOrderCalculator,
-                                     ScanResult scanResult, List<CommandLineOption> mainCliOptions,
-                                     int skipAfterFailureCount )
+    TestNGDirectoryTestSuite( String testSourceDirectory, Map<String, String> confOptions, File reportsDirectory,
+                              TestListResolver methodFilter, List<CommandLineOption> mainCliOptions,
+                              int skipAfterFailureCount )
     {
-        this.runOrderCalculator = runOrderCalculator;
         this.options = confOptions;
         this.testSourceDirectory = testSourceDirectory;
         this.reportsDirectory = reportsDirectory;
-        this.scanResult = scanResult;
         this.methodFilter = methodFilter;
         this.junitTestClass = findJUnitTestClass();
         this.junitRunWithAnnotation = findJUnitRunWithAnnotation();
@@ -100,63 +81,59 @@ public class TestNGDirectoryTestSuite
         this.skipAfterFailureCount = skipAfterFailureCount;
     }
 
-    public void execute( TestsToRun testsToRun, ReporterFactory reporterManagerFactory )
+    void execute( TestsToRun testsToRun, RunListener reporterManager )
         throws TestSetFailedException
     {
-
         if ( !testsToRun.allowEagerReading() )
         {
-            executeLazy( testsToRun, reporterManagerFactory );
+            executeLazy( testsToRun, reporterManager );
         }
         else if ( testsToRun.containsAtLeast( 2 ) )
         {
-            executeMulti( testsToRun, reporterManagerFactory );
+            executeMulti( testsToRun, reporterManager );
         }
         else if ( testsToRun.containsAtLeast( 1 ) )
         {
             Class<?> testClass = testsToRun.iterator().next();
-            executeSingleClass( reporterManagerFactory, testClass );
+            executeSingleClass( reporterManager, testClass );
         }
     }
 
-    private void executeSingleClass( ReporterFactory reporterManagerFactory, Class<?> testClass )
+    private void executeSingleClass( RunListener reporter, Class<?> testClass )
         throws TestSetFailedException
     {
         options.put( "suitename", testClass.getName() );
 
-        RunListener reporter = reporterManagerFactory.createReporter();
-        ConsoleOutputCapture.startCapture( (ConsoleOutputReceiver) reporter );
-
         startTestSuite( reporter, this );
 
         final Map<String, String> optionsToUse = isJUnitTest( testClass ) ? junitOptions : options;
 
-        TestNGExecutor.run( new Class<?>[]{ testClass }, testSourceDirectory, optionsToUse, reporter, this,
+        TestNGExecutor.run( new Class<?>[]{ testClass }, testSourceDirectory, optionsToUse, reporter,
                             reportsDirectory, methodFilter, mainCliOptions, skipAfterFailureCount );
 
         finishTestSuite( reporter, this );
     }
 
-    public void executeLazy( TestsToRun testsToRun, ReporterFactory reporterFactory )
+    private void executeLazy( TestsToRun testsToRun, RunListener reporterManager )
         throws TestSetFailedException
     {
         for ( Class<?> c : testsToRun )
         {
-            executeSingleClass( reporterFactory, c );
+            executeSingleClass( reporterManager, c );
         }
     }
 
-    private Class<?> findJUnitTestClass()
+    private static Class<?> findJUnitTestClass()
     {
         return lookupClass( "junit.framework.Test" );
     }
 
-    private Class<Annotation> findJUnitRunWithAnnotation()
+    private static Class<Annotation> findJUnitRunWithAnnotation()
     {
         return lookupAnnotation( "org.junit.runner.RunWith" );
     }
 
-    private Class<Annotation> findJUnitTestAnnotation()
+    private static Class<Annotation> findJUnitTestAnnotation()
     {
         return lookupAnnotation( "org.junit.Test" );
     }
@@ -186,7 +163,7 @@ public class TestNGDirectoryTestSuite
         }
     }
 
-    public void executeMulti( TestsToRun testsToRun, ReporterFactory reporterFactory )
+    private void executeMulti( TestsToRun testsToRun, RunListener reporterManager )
         throws TestSetFailedException
     {
         List<Class<?>> testNgTestClasses = new ArrayList<Class<?>>();
@@ -210,21 +187,18 @@ public class TestNGDirectoryTestSuite
             testNgReportsDirectory = new File( reportsDirectory, "testng-native-results" );
             junitReportsDirectory = new File( reportsDirectory, "testng-junit-results" );
         }
-
-        RunListener reporterManager = reporterFactory.createReporter();
-        ConsoleOutputCapture.startCapture( (ConsoleOutputReceiver) reporterManager );
         startTestSuite( reporterManager, this );
 
         Class<?>[] testClasses = testNgTestClasses.toArray( new Class<?>[testNgTestClasses.size()] );
 
-        TestNGExecutor.run( testClasses, testSourceDirectory, options, reporterManager, this,
+        TestNGExecutor.run( testClasses, testSourceDirectory, options, reporterManager,
                             testNgReportsDirectory, methodFilter, mainCliOptions, skipAfterFailureCount );
 
         if ( !junitTestClasses.isEmpty() )
         {
             testClasses = junitTestClasses.toArray( new Class[junitTestClasses.size()] );
 
-            TestNGExecutor.run( testClasses, testSourceDirectory, junitOptions, reporterManager, this,
+            TestNGExecutor.run( testClasses, testSourceDirectory, junitOptions, reporterManager,
                                 junitReportsDirectory, methodFilter, mainCliOptions, skipAfterFailureCount );
         }
 
@@ -269,44 +243,18 @@ public class TestNGDirectoryTestSuite
 
     private Map<String, String> createJUnitOptions()
     {
-        Map<String, String> junitOptions = new HashMap<String, String>( this.options );
+        Map<String, String> junitOptions = new HashMap<String, String>( options );
         junitOptions.put( "junit", "true" );
         return junitOptions;
     }
 
-    // single class test
-    public void execute( String testSetName, ReporterFactory reporterManagerFactory )
-        throws TestSetFailedException
-    {
-        if ( testSets == null )
-        {
-            throw new IllegalStateException( "You must call locateTestSets before calling execute" );
-        }
-        TestNGTestSet testSet = testSets.get( testSetName );
-
-        if ( testSet == null )
-        {
-            throw new TestSetFailedException( "Unable to find test set '" + testSetName + "' in suite" );
-        }
-
-        RunListener reporter = reporterManagerFactory.createReporter();
-        ConsoleOutputCapture.startCapture( (ConsoleOutputReceiver) reporter );
-
-        startTestSuite( reporter, this );
-
-        TestNGExecutor.run( new Class<?>[] { testSet.getTestClass() }, testSourceDirectory, options, reporter,
-                            this, reportsDirectory, methodFilter, mainCliOptions, skipAfterFailureCount );
-
-        finishTestSuite( reporter, this );
-    }
-
-    public static void startTestSuite( RunListener reporter, Object suite )
+    public static void startTestSuite( RunListener reporterManager, Object suite )
     {
         ReportEntry report = new SimpleReportEntry( suite.getClass().getName(), getSuiteName( suite ) );
 
         try
         {
-            reporter.testSetStarting( report );
+            reporterManager.testSetStarting( report );
         }
         catch ( ReporterException e )
         {
@@ -321,7 +269,7 @@ public class TestNGDirectoryTestSuite
         reporterManager.testSetCompleted( report );
     }
 
-    public String getSuiteName()
+    String getSuiteName()
     {
         String result = options.get( "suitename" );
         return result == null ? "TestSuite" : result;
@@ -341,32 +289,4 @@ public class TestNGDirectoryTestSuite
 
         return result;
     }
-
-    public Map locateTestSets( ClassLoader classLoader )
-        throws TestSetFailedException
-    {
-        if ( testSets != null )
-        {
-            throw new IllegalStateException( "You can't call locateTestSets twice" );
-        }
-        testSets = new TreeMap<String, TestNGTestSet>();
-
-        final TestsToRun scanned = scanResult.applyFilter( new NonAbstractClassFilter(), classLoader );
-
-        final TestsToRun testsToRun = runOrderCalculator.orderTestClasses( scanned );
-
-        for ( Class<?> testClass : testsToRun )
-        {
-            TestNGTestSet testSet = new TestNGTestSet( testClass );
-
-            if ( testSets.containsKey( testSet.getName() ) )
-            {
-                throw new TestSetFailedException( "Duplicate test set '" + testSet.getName() + "'" );
-            }
-            testSets.put( testSet.getName(), testSet );
-        }
-
-        return Collections.unmodifiableSortedMap( testSets );
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/9cefb7ba/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java
index 05f7871..7d7700a 100644
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java
@@ -57,7 +57,7 @@ import static org.apache.maven.surefire.util.internal.ConcurrencyUtils.countDown
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
  * @author <a href='mailto:the[dot]mindstorm[at]gmail[dot]com'>Alex Popescu</a>
  */
-public class TestNGExecutor
+final class TestNGExecutor
 {
     /** The default name for a suite launched from the maven surefire plugin */
     public static final String DEFAULT_SUREFIRE_SUITE_NAME = "Surefire suite";
@@ -70,12 +70,12 @@ public class TestNGExecutor
 
     private TestNGExecutor()
     {
-        // noop
+        throw new IllegalStateException( "not instantiable constructor" );
     }
 
-    public static void run( Class<?>[] testClasses, String testSourceDirectory,
+    static void run( Class<?>[] testClasses, String testSourceDirectory,
                             Map<String, String> options, // string,string because TestNGMapConfigurator#configure()
-                            RunListener reportManager, TestNgTestSuite suite, File reportsDirectory,
+                            RunListener reportManager, File reportsDirectory,
                             TestListResolver methodFilter, List<CommandLineOption> mainCliOptions,
                             int skipAfterFailureCount )
         throws TestSetFailedException
@@ -127,7 +127,7 @@ public class TestNGExecutor
 
         testng.setXmlSuites( xmlSuites );
         configurator.configure( testng, options );
-        postConfigure( testng, testSourceDirectory, reportManager, suite, reportsDirectory, skipAfterFailureCount,
+        postConfigure( testng, testSourceDirectory, reportManager, reportsDirectory, skipAfterFailureCount,
                        extractVerboseLevel( options ) );
         testng.run();
     }
@@ -269,14 +269,13 @@ public class TestNGExecutor
 
     public static void run( List<String> suiteFiles, String testSourceDirectory,
                             Map<String, String> options, // string,string because TestNGMapConfigurator#configure()
-                            RunListener reportManager, TestNgTestSuite suite, File reportsDirectory,
-                            int skipAfterFailureCount )
+                            RunListener reportManager, File reportsDirectory, int skipAfterFailureCount )
         throws TestSetFailedException
     {
         TestNG testng = new TestNG( true );
         Configurator configurator = getConfigurator( options.get( "testng.configurator" ) );
         configurator.configure( testng, options );
-        postConfigure( testng, testSourceDirectory, reportManager, suite, reportsDirectory, skipAfterFailureCount,
+        postConfigure( testng, testSourceDirectory, reportManager, reportsDirectory, skipAfterFailureCount,
                        extractVerboseLevel( options ) );
         testng.setTestSuites( suiteFiles );
         testng.run();
@@ -303,13 +302,12 @@ public class TestNGExecutor
     }
 
     private static void postConfigure( TestNG testNG, String sourcePath, final RunListener reportManager,
-                                       TestNgTestSuite suite, File reportsDirectory, int skipAfterFailureCount,
-                                       int verboseLevel )
+                                       File reportsDirectory, int skipAfterFailureCount, int verboseLevel )
     {
         // 0 (default): turn off all TestNG output
         testNG.setVerbose( verboseLevel );
 
-        TestNGReporter reporter = createTestNGReporter( reportManager, suite );
+        TestNGReporter reporter = createTestNGReporter( reportManager );
         testNG.addListener( (Object) reporter );
 
         if ( skipAfterFailureCount > 0 )
@@ -349,15 +347,14 @@ public class TestNGExecutor
 
     // If we have access to IResultListener, return a ConfigurationAwareTestNGReporter
     // But don't cause NoClassDefFoundErrors if it isn't available; just return a regular TestNGReporter instead
-    private static TestNGReporter createTestNGReporter( RunListener reportManager, TestNgTestSuite suite )
+    private static TestNGReporter createTestNGReporter( RunListener reportManager )
     {
         try
         {
             Class.forName( "org.testng.internal.IResultListener" );
             Class c = Class.forName( "org.apache.maven.surefire.testng.ConfigurationAwareTestNGReporter" );
-            @SuppressWarnings( "unchecked" ) Constructor<?> ctor =
-                    c.getConstructor( RunListener.class, TestNgTestSuite.class );
-            return (TestNGReporter) ctor.newInstance( reportManager, suite );
+            @SuppressWarnings( "unchecked" ) Constructor<?> ctor = c.getConstructor( RunListener.class );
+            return (TestNGReporter) ctor.newInstance( reportManager );
         }
         catch ( InvocationTargetException e )
         {
@@ -387,5 +384,4 @@ public class TestNGExecutor
                                                   + "number -1 (debug mode), 0, 1 .. 10 (most detailed).", e );
         }
     }
-
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/9cefb7ba/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java
index c53a8e2..91117d2 100644
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java
@@ -25,8 +25,11 @@ import org.apache.maven.surefire.booter.CommandReader;
 import org.apache.maven.surefire.cli.CommandLineOption;
 import org.apache.maven.surefire.providerapi.AbstractProvider;
 import org.apache.maven.surefire.providerapi.ProviderParameters;
+import org.apache.maven.surefire.report.ConsoleOutputCapture;
+import org.apache.maven.surefire.report.ConsoleOutputReceiver;
 import org.apache.maven.surefire.report.ReporterConfiguration;
 import org.apache.maven.surefire.report.ReporterFactory;
+import org.apache.maven.surefire.report.RunListener;
 import org.apache.maven.surefire.suite.RunResult;
 import org.apache.maven.surefire.testng.utils.FailFastEventsSingleton;
 import org.apache.maven.surefire.testset.TestListResolver;
@@ -38,6 +41,7 @@ import org.apache.maven.surefire.util.TestsToRun;
 
 import java.io.File;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
@@ -101,6 +105,8 @@ public class TestNGProvider
         }
 
         final ReporterFactory reporterFactory = providerParameters.getReporterFactory();
+        final RunListener reporter = reporterFactory.createReporter();
+        ConsoleOutputCapture.startCapture( (ConsoleOutputReceiver) reporter );
         RunResult runResult;
 
         try
@@ -108,15 +114,8 @@ public class TestNGProvider
             if ( isTestNGXmlTestSuite( testRequest ) )
             {
                 TestNGXmlTestSuite testNGXmlTestSuite = newXmlSuite();
-                testNGXmlTestSuite.locateTestSets( testClassLoader );
-                if ( forkTestSet != null && testRequest == null )
-                {
-                    testNGXmlTestSuite.execute( (String) forkTestSet, reporterFactory );
-                }
-                else
-                {
-                    testNGXmlTestSuite.execute( reporterFactory );
-                }
+                testNGXmlTestSuite.locateTestSets();
+                testNGXmlTestSuite.execute( reporter );
             }
             else
             {
@@ -147,7 +146,7 @@ public class TestNGProvider
                     } );
                 }
                 TestNGDirectoryTestSuite suite = newDirectorySuite();
-                suite.execute( testsToRun, reporterFactory );
+                suite.execute( testsToRun, reporter );
             }
         }
         finally
@@ -190,8 +189,7 @@ public class TestNGProvider
     {
         return new TestNGDirectoryTestSuite( testRequest.getTestSourceDirectory().toString(), providerProperties,
                                              reporterConfiguration.getReportsDirectory(), getTestFilter(),
-                                             runOrderCalculator, scanResult, mainCliOptions,
-                                             getSkipAfterFailureCount() );
+                                             mainCliOptions, getSkipAfterFailureCount() );
     }
 
     private TestNGXmlTestSuite newXmlSuite()
@@ -202,19 +200,11 @@ public class TestNGProvider
                                        reporterConfiguration.getReportsDirectory(), getSkipAfterFailureCount() );
     }
 
-    @SuppressWarnings( "unchecked" )
     public Iterable<Class<?>> getSuites()
     {
         if ( isTestNGXmlTestSuite( testRequest ) )
         {
-            try
-            {
-                return newXmlSuite().locateTestSets( testClassLoader ).keySet();
-            }
-            catch ( TestSetFailedException e )
-            {
-                throw new RuntimeException( e );
-            }
+            return Collections.emptySet();
         }
         else
         {

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/9cefb7ba/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGXmlTestSuite.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGXmlTestSuite.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGXmlTestSuite.java
index f493fe7..4617110 100644
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGXmlTestSuite.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGXmlTestSuite.java
@@ -21,15 +21,11 @@ package org.apache.maven.surefire.testng;
 
 import java.io.File;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import org.apache.maven.surefire.report.ConsoleOutputReceiver;
-import org.apache.maven.surefire.report.ReporterFactory;
 import org.apache.maven.surefire.report.RunListener;
 import org.apache.maven.surefire.testset.TestSetFailedException;
 
-import static org.apache.maven.surefire.report.ConsoleOutputCapture.startCapture;
 import static org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.finishTestSuite;
 import static org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.startTestSuite;
 import static org.apache.maven.surefire.testng.TestNGExecutor.run;
@@ -40,10 +36,9 @@ import static org.apache.maven.surefire.testng.TestNGExecutor.run;
  * @author jkuhnert
  * @author <a href='mailto:the[dot]mindstorm[at]gmail[dot]com'>Alex Popescu</a>
  */
-public class TestNGXmlTestSuite
-    implements TestNgTestSuite
+final class TestNGXmlTestSuite
 {
-    private final List suiteFiles;
+    private final List<File> suiteFiles;
 
     private List<String> suiteFilePaths;
 
@@ -55,15 +50,12 @@ public class TestNGXmlTestSuite
 
     private final int skipAfterFailureCount;
 
-    // Not really used
-    private Map<File, String> testSets;
-
     /**
      * Creates a testng testset to be configured by the specified
      * xml file(s). The XML files are suite definitions files according to TestNG DTD.
      */
-    public TestNGXmlTestSuite( List<File> suiteFiles, String testSourceDirectory, Map<String, String> confOptions,
-                               File reportsDirectory, int skipAfterFailureCount )
+    TestNGXmlTestSuite( List<File> suiteFiles, String testSourceDirectory, Map<String, String> confOptions,
+                        File reportsDirectory, int skipAfterFailureCount )
     {
         this.suiteFiles = suiteFiles;
         this.options = confOptions;
@@ -72,30 +64,22 @@ public class TestNGXmlTestSuite
         this.skipAfterFailureCount = skipAfterFailureCount;
     }
 
-    public void execute( ReporterFactory reporterManagerFactory )
+    void execute( RunListener reporter )
         throws TestSetFailedException
     {
-        if ( testSets == null )
+        if ( suiteFilePaths == null )
         {
             throw new IllegalStateException( "You must call locateTestSets before calling execute" );
         }
-        RunListener reporter = reporterManagerFactory.createReporter();
-        startCapture( (ConsoleOutputReceiver) reporter );
         startTestSuite( reporter, this );
-        run( suiteFilePaths, testSourceDirectory, options, reporter, this, reportsDirectory, skipAfterFailureCount );
+        run( suiteFilePaths, testSourceDirectory, options, reporter, reportsDirectory, skipAfterFailureCount );
         finishTestSuite( reporter, this );
     }
 
-    public void execute( String testSetName, ReporterFactory reporterManagerFactory )
-        throws TestSetFailedException
-    {
-        throw new TestSetFailedException( "Cannot run individual test when suite files are specified" );
-    }
-
-    public Map locateTestSets( ClassLoader classLoader )
+    void locateTestSets()
         throws TestSetFailedException
     {
-        if ( testSets != null )
+        if ( suiteFilePaths != null )
         {
             throw new IllegalStateException( "You can't call locateTestSets twice" );
         }
@@ -105,24 +89,19 @@ public class TestNGXmlTestSuite
             throw new IllegalStateException( "No suite files were specified" );
         }
 
-        testSets = new HashMap<File, String>();
         suiteFilePaths = new ArrayList<String>();
 
-        for ( Object suiteFile : suiteFiles )
+        for ( File suiteFile : suiteFiles )
         {
-            File file = (File) suiteFile;
-            if ( !file.exists() || !file.isFile() )
+            if ( !suiteFile.isFile() )
             {
-                throw new TestSetFailedException( "Suite file " + file + " is not a valid file" );
+                throw new TestSetFailedException( "Suite file " + suiteFile + " is not a valid file" );
             }
-            testSets.put( file, file.getAbsolutePath() );
-            suiteFilePaths.add( file.getAbsolutePath() );
+            suiteFilePaths.add( suiteFile.getAbsolutePath() );
         }
-
-        return testSets;
     }
 
-    public String getSuiteName()
+    String getSuiteName()
     {
         String result = options.get( "suitename" );
         return result == null ? "TestSuite" : result;

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/9cefb7ba/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNgTestSuite.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNgTestSuite.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNgTestSuite.java
deleted file mode 100644
index a1d8e0f..0000000
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNgTestSuite.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.apache.maven.surefire.testng;
-
-/*
- * 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.util.Map;
-import org.apache.maven.surefire.report.ReporterFactory;
-import org.apache.maven.surefire.testset.TestSetFailedException;
-
-/**
- * A complete test suite that contains one or more test sets.
- *
- * @author <a href="mailto:brett@apache.org">Brett Porter</a>
- */
-public interface TestNgTestSuite
-{
-
-    void execute( String testSetName, ReporterFactory reporterManagerFactory )
-        throws TestSetFailedException;
-
-    Map locateTestSets( ClassLoader classLoader )
-        throws TestSetFailedException;
-}