maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krosenv...@apache.org
Subject svn commit: r1203992 - in /maven/surefire/trunk: surefire-api/src/main/java/org/apache/maven/surefire/booter/ surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ surefire-api/src/main/java/org/apache/maven/surefire/util/ surefire-api/src/...
Date Sat, 19 Nov 2011 15:30:03 GMT
Author: krosenvold
Date: Sat Nov 19 15:30:02 2011
New Revision: 1203992

URL: http://svn.apache.org/viewvc?rev=1203992&view=rev
Log:
o Extracted run-order calulation into seperate service

In preparation of funky things to come

Added:
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultRunOrderCalculator.java
  (with props)
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/RunOrderCalculator.java
  (with props)
    maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/RunOrderCalculatorTest.java
  (with props)
Modified:
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/BaseProviderFactory.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderParameters.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java
    maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/SurefireDirectoryScannerTest.java
    maven/surefire/trunk/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java
    maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.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/TestNGProvider.java

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/BaseProviderFactory.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/BaseProviderFactory.java?rev=1203992&r1=1203991&r2=1203992&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/BaseProviderFactory.java
(original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/BaseProviderFactory.java
Sat Nov 19 15:30:02 2011
@@ -30,7 +30,9 @@ import org.apache.maven.surefire.testset
 import org.apache.maven.surefire.testset.TestArtifactInfo;
 import org.apache.maven.surefire.testset.TestRequest;
 import org.apache.maven.surefire.util.DefaultDirectoryScanner;
+import org.apache.maven.surefire.util.DefaultRunOrderCalculator;
 import org.apache.maven.surefire.util.DirectoryScanner;
+import org.apache.maven.surefire.util.RunOrderCalculator;
 
 /**
  * @author Kristian Rosenvold
@@ -39,6 +41,7 @@ public class BaseProviderFactory
     implements DirectoryScannerParametersAware, ReporterConfigurationAware, SurefireClassLoadersAware,
TestRequestAware,
     ProviderPropertiesAware, ProviderParameters, TestArtifactInfoAware
 {
+
     private Properties providerProperties;
 
     private DirectoryScannerParameters directoryScannerParameters;
@@ -69,8 +72,16 @@ public class BaseProviderFactory
         }
         return new DefaultDirectoryScanner( directoryScannerParameters.getTestClassesDirectory(),
                                             directoryScannerParameters.getIncludes(),
-                                            directoryScannerParameters.getExcludes(),
-                                            directoryScannerParameters.getRunOrder() );
+                                            directoryScannerParameters.getExcludes() );
+    }
+
+    public RunOrderCalculator getRunOrderCalculator()
+    {
+        if ( directoryScannerParameters == null )
+        {
+            return null;
+        }
+        return new DefaultRunOrderCalculator( directoryScannerParameters.getRunOrder() );
     }
 
     public ReporterFactory getReporterFactory()

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderParameters.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderParameters.java?rev=1203992&r1=1203991&r2=1203992&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderParameters.java
(original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderParameters.java
Sat Nov 19 15:30:02 2011
@@ -27,6 +27,7 @@ import org.apache.maven.surefire.testset
 import org.apache.maven.surefire.testset.TestArtifactInfo;
 import org.apache.maven.surefire.testset.TestRequest;
 import org.apache.maven.surefire.util.DirectoryScanner;
+import org.apache.maven.surefire.util.RunOrderCalculator;
 
 /**
  * Injected into the providers upon provider construction. Allows the provider to request
services and data it needs.
@@ -49,6 +50,12 @@ public interface ProviderParameters
     DirectoryScanner getDirectoryScanner();
 
     /**
+     * Provides a service to calculate run order of tests. Applied after directory scanning.
+     * @return A RunOrderCalculator
+     */
+    RunOrderCalculator getRunOrderCalculator();
+
+    /**
      * Provides features for creating reporting objects
      *
      * @return A ReporterFactory that allows the creation of one or more ReporterManagers

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java?rev=1203992&r1=1203991&r2=1203992&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java
(original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java
Sat Nov 19 15:30:02 2011
@@ -21,9 +21,6 @@ package org.apache.maven.surefire.util;
 
 import java.io.File;
 import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Comparator;
 import java.util.Iterator;
 import java.util.List;
 
@@ -53,17 +50,11 @@ public class DefaultDirectoryScanner
 
     private final List classesSkippedByValidation = new ArrayList();
 
-    private final Comparator sortOrder;
-
-    private final RunOrder runOrder;
-
-    public DefaultDirectoryScanner( File basedir, List includes, List excludes, RunOrder
runOrder )
+    public DefaultDirectoryScanner( File basedir, List includes, List excludes )
     {
         this.basedir = basedir;
         this.includes = includes;
         this.excludes = excludes;
-        this.runOrder = runOrder;
-        this.sortOrder = getSortOrderComparator();
     }
 
     public TestsToRun locateTestClasses( ClassLoader classLoader, ScannerFilter scannerFilter
)
@@ -86,7 +77,6 @@ public class DefaultDirectoryScanner
                 classesSkippedByValidation.add( testClass );
             }
         }
-        orderTestClasses( result );
         return new TestsToRun( result );
     }
 
@@ -173,59 +163,4 @@ public class DefaultDirectoryScanner
         return classesSkippedByValidation;
     }
 
-    private void orderTestClasses( List testClasses )
-    {
-        if ( RunOrder.RANDOM.equals( runOrder ) )
-        {
-            Collections.shuffle( testClasses );
-        }
-        else if ( sortOrder != null )
-        {
-            Collections.sort( testClasses, sortOrder );
-        }
-    }
-
-    private Comparator getSortOrderComparator()
-    {
-        if ( RunOrder.ALPHABETICAL.equals( runOrder ) )
-        {
-            return getAlphabeticalComparator();
-        }
-        else if ( RunOrder.REVERSE_ALPHABETICAL.equals( runOrder ) )
-        {
-            return getReverseAlphabeticalComparator();
-        }
-        else if ( RunOrder.HOURLY.equals( runOrder ) )
-        {
-            final int hour = Calendar.getInstance().get( Calendar.HOUR_OF_DAY );
-            return ( ( hour % 2 ) == 0 ) ? getAlphabeticalComparator() : getReverseAlphabeticalComparator();
-        }
-        else
-        {
-            return null;
-        }
-    }
-
-    private Comparator getReverseAlphabeticalComparator()
-    {
-        return new Comparator()
-        {
-            public int compare( Object o1, Object o2 )
-            {
-                return ( (Class) o2 ).getName().compareTo( ( (Class) o1 ).getName() );
-            }
-        };
-    }
-
-    private Comparator getAlphabeticalComparator()
-    {
-        return new Comparator()
-        {
-            public int compare( Object o1, Object o2 )
-            {
-                return ( (Class) o1 ).getName().compareTo( ( (Class) o2 ).getName() );
-            }
-        };
-    }
-
 }

Added: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultRunOrderCalculator.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultRunOrderCalculator.java?rev=1203992&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultRunOrderCalculator.java
(added)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultRunOrderCalculator.java
Sat Nov 19 15:30:02 2011
@@ -0,0 +1,109 @@
+package org.apache.maven.surefire.util;
+
+/*
+ * 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.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ * Applies the final unorder of the tests
+ * 
+ * @author Kristian Rosenvold
+ */
+public class DefaultRunOrderCalculator
+    implements RunOrderCalculator
+{
+    private final Comparator sortOrder;
+
+    private final RunOrder runOrder;
+
+    public DefaultRunOrderCalculator( RunOrder runOrder )
+    {
+        this.runOrder = runOrder;
+        this.sortOrder = getSortOrderComparator();
+    }
+
+  public TestsToRun orderTestClasses( TestsToRun scannedClasses ){
+    List result = new ArrayList(Arrays.asList(scannedClasses.getLocatedClasses()));
+    orderTestClasses(result);
+    return new TestsToRun( result );
+
+  }
+
+  private void orderTestClasses( List testClasses )
+    {
+        if ( RunOrder.RANDOM.equals( runOrder ) )
+        {
+            Collections.shuffle( testClasses );
+        }
+        else if ( sortOrder != null )
+        {
+            Collections.sort( testClasses, sortOrder );
+        }
+    }
+
+    private Comparator getSortOrderComparator()
+    {
+        if ( RunOrder.ALPHABETICAL.equals( runOrder ) )
+        {
+            return getAlphabeticalComparator();
+        }
+        else if ( RunOrder.REVERSE_ALPHABETICAL.equals( runOrder ) )
+        {
+            return getReverseAlphabeticalComparator();
+        }
+        else if ( RunOrder.HOURLY.equals( runOrder ) )
+        {
+            final int hour = Calendar.getInstance().get( Calendar.HOUR_OF_DAY );
+            return ( ( hour % 2 ) == 0 ) ? getAlphabeticalComparator() : getReverseAlphabeticalComparator();
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+    private Comparator getReverseAlphabeticalComparator()
+    {
+        return new Comparator()
+        {
+            public int compare( Object o1, Object o2 )
+            {
+                return ( (Class) o2 ).getName().compareTo( ( (Class) o1 ).getName() );
+            }
+        };
+    }
+
+    private Comparator getAlphabeticalComparator()
+    {
+        return new Comparator()
+        {
+            public int compare( Object o1, Object o2 )
+            {
+                return ( (Class) o1 ).getName().compareTo( ( (Class) o2 ).getName() );
+            }
+        };
+    }
+
+}

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

Added: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/RunOrderCalculator.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/RunOrderCalculator.java?rev=1203992&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/RunOrderCalculator.java
(added)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/RunOrderCalculator.java
Sat Nov 19 15:30:02 2011
@@ -0,0 +1,29 @@
+package org.apache.maven.surefire.util;
+
+
+/*
+ * 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.
+ */
+
+/**
+ * @author Kristian Rosenvold
+ */
+public interface RunOrderCalculator
+{
+    TestsToRun orderTestClasses( TestsToRun scannedClasses );
+}

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

Added: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/RunOrderCalculatorTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/RunOrderCalculatorTest.java?rev=1203992&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/RunOrderCalculatorTest.java
(added)
+++ maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/RunOrderCalculatorTest.java
Sat Nov 19 15:30:02 2011
@@ -0,0 +1,38 @@
+package org.apache.maven.surefire.util;
+
+import junit.framework.TestCase;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Kristian Rosenvold
+ */
+public class RunOrderCalculatorTest extends TestCase {
+
+  public void testOrderTestClasses() throws Exception {
+    getClassesToRun();
+    TestsToRun testsToRun = new TestsToRun(getClassesToRun());
+    RunOrderCalculator runOrderCalculator = new DefaultRunOrderCalculator(RunOrder.ALPHABETICAL);
+    final TestsToRun testsToRun1 = runOrderCalculator.orderTestClasses(testsToRun);
+    assertEquals( A.class, testsToRun1.iterator().next());
+
+  }
+
+  private List getClassesToRun() {
+    List classesToRun = new ArrayList();
+    classesToRun.add( B.class);
+    classesToRun.add( A.class);
+    return classesToRun;
+  }
+
+  class A {
+
+  }
+
+  class B {
+
+  }
+
+
+}

Propchange: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/RunOrderCalculatorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/SurefireDirectoryScannerTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/SurefireDirectoryScannerTest.java?rev=1203992&r1=1203991&r2=1203992&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/SurefireDirectoryScannerTest.java
(original)
+++ maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/SurefireDirectoryScannerTest.java
Sat Nov 19 15:30:02 2011
@@ -43,8 +43,7 @@ public class SurefireDirectoryScannerTes
         include.add( "**/*ZT*A.java" );
         List exclude = new ArrayList();
 
-        DefaultDirectoryScanner surefireDirectoryScanner = new DefaultDirectoryScanner( baseDir,
include, exclude,
-                                                                                        RunOrder.FILESYSTEM
);
+        DefaultDirectoryScanner surefireDirectoryScanner = new DefaultDirectoryScanner( baseDir,
include, exclude );
         String[] classNames = surefireDirectoryScanner.collectTests();
         assertNotNull( classNames );
         System.out.println("classNames " + Arrays.asList( classNames ));

Modified: maven/surefire/trunk/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java?rev=1203992&r1=1203991&r2=1203992&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java
(original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java
Sat Nov 19 15:30:02 2011
@@ -35,6 +35,7 @@ import org.apache.maven.surefire.suite.R
 import org.apache.maven.surefire.testset.TestSetFailedException;
 import org.apache.maven.surefire.util.DirectoryScanner;
 import org.apache.maven.surefire.util.ReflectionUtils;
+import org.apache.maven.surefire.util.RunOrderCalculator;
 import org.apache.maven.surefire.util.TestsToRun;
 
 /**
@@ -55,13 +56,16 @@ public class JUnit3Provider
 
     private final ProviderParameters providerParameters;
 
+    private final RunOrderCalculator runOrderCalculator;
+
     private TestsToRun testsToRun;
 
-    public JUnit3Provider( ProviderParameters booterParameters )
+  public JUnit3Provider( ProviderParameters booterParameters )
     {
         this.providerParameters = booterParameters;
         this.testClassLoader = booterParameters.getTestClassLoader();
         this.directoryScanner = booterParameters.getDirectoryScanner();
+        this.runOrderCalculator = booterParameters.getRunOrderCalculator();
         this.reflector = new JUnit3Reflector( testClassLoader );
         jUnit3TestChecker = new JUnit3TestChecker( testClassLoader );
         this.testChecker = new PojoAndJUnit3Checker( jUnit3TestChecker ); // Todo; use reflector
@@ -121,7 +125,8 @@ public class JUnit3Provider
 
     private TestsToRun scanClassPath()
     {
-        return directoryScanner.locateTestClasses( testClassLoader, testChecker );
+        final TestsToRun scanResult = directoryScanner.locateTestClasses( testClassLoader,
testChecker );
+        return runOrderCalculator.orderTestClasses(  scanResult );
     }
 
     public Iterator getSuites()

Modified: maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java?rev=1203992&r1=1203991&r2=1203992&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
(original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
Sat Nov 19 15:30:02 2011
@@ -38,6 +38,7 @@ import org.apache.maven.surefire.suite.R
 import org.apache.maven.surefire.testset.TestSetFailedException;
 import org.apache.maven.surefire.util.DefaultDirectoryScanner;
 import org.apache.maven.surefire.util.DirectoryScanner;
+import org.apache.maven.surefire.util.RunOrderCalculator;
 import org.apache.maven.surefire.util.TestsToRun;
 
 import org.junit.runner.Result;
@@ -63,11 +64,15 @@ public class JUnit4Provider
 
     private final ProviderParameters providerParameters;
 
+    private final RunOrderCalculator runOrderCalculator;
+
+
     public JUnit4Provider( ProviderParameters booterParameters )
     {
         this.providerParameters = booterParameters;
         this.testClassLoader = booterParameters.getTestClassLoader();
         this.directoryScanner = booterParameters.getDirectoryScanner();
+        this.runOrderCalculator = booterParameters.getRunOrderCalculator();
         customRunListeners = JUnit4RunListenerFactory.
             createCustomListeners( booterParameters.getProviderProperties().getProperty(
"listener" ) );
         jUnit4TestChecker = new JUnit4TestChecker( testClassLoader );
@@ -171,7 +176,8 @@ public class JUnit4Provider
 
     private TestsToRun scanClassPath()
     {
-        return directoryScanner.locateTestClasses( testClassLoader, jUnit4TestChecker );
+        final TestsToRun scannedClasses = directoryScanner.locateTestClasses( testClassLoader,
jUnit4TestChecker );
+        return runOrderCalculator.orderTestClasses(  scannedClasses );
     }
 
     private void upgradeCheck()

Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java?rev=1203992&r1=1203991&r2=1203992&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
(original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
Sat Nov 19 15:30:02 2011
@@ -40,6 +40,7 @@ import org.apache.maven.surefire.report.
 import org.apache.maven.surefire.suite.RunResult;
 import org.apache.maven.surefire.testset.TestSetFailedException;
 import org.apache.maven.surefire.util.DirectoryScanner;
+import org.apache.maven.surefire.util.RunOrderCalculator;
 import org.apache.maven.surefire.util.ScannerFilter;
 import org.apache.maven.surefire.util.TestsToRun;
 
@@ -65,15 +66,20 @@ public class JUnitCoreProvider
 
     private final ProviderParameters providerParameters;
 
+
+
     private TestsToRun testsToRun;
 
     private JUnit48Reflector jUnit48Reflector;
 
+    private RunOrderCalculator runOrderCalculator;
+
     public JUnitCoreProvider( ProviderParameters providerParameters )
     {
         this.providerParameters = providerParameters;
         this.testClassLoader = providerParameters.getTestClassLoader();
         this.directoryScanner = providerParameters.getDirectoryScanner();
+        this.runOrderCalculator = providerParameters.getRunOrderCalculator();
         this.jUnitCoreParameters = new JUnitCoreParameters( providerParameters.getProviderProperties()
);
         this.scannerFilter = new JUnit4TestChecker( testClassLoader );
         customRunListeners = JUnit4RunListenerFactory.
@@ -168,6 +174,7 @@ public class JUnitCoreProvider
 
     private TestsToRun scanClassPath()
     {
-        return directoryScanner.locateTestClasses( testClassLoader, scannerFilter );
+        final TestsToRun scanned = directoryScanner.locateTestClasses( testClassLoader, scannerFilter
);
+        return  runOrderCalculator.orderTestClasses(  scanned );
     }
 }

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=1203992&r1=1203991&r2=1203992&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
Sat Nov 19 15:30:02 2011
@@ -42,8 +42,10 @@ import org.apache.maven.surefire.report.
 import org.apache.maven.surefire.report.SimpleReportEntry;
 import org.apache.maven.surefire.testset.TestSetFailedException;
 import org.apache.maven.surefire.util.DefaultDirectoryScanner;
+import org.apache.maven.surefire.util.DefaultRunOrderCalculator;
 import org.apache.maven.surefire.util.DirectoryScanner;
 import org.apache.maven.surefire.util.RunOrder;
+import org.apache.maven.surefire.util.RunOrderCalculator;
 import org.apache.maven.surefire.util.TestsToRun;
 
 /**
@@ -69,12 +71,15 @@ public class TestNGDirectoryTestSuite
 
     private final String testMethodPattern;
 
+    private final RunOrderCalculator runOrderCalculator;
+
     public TestNGDirectoryTestSuite( File basedir, ArrayList includes, ArrayList excludes,
String testSourceDirectory,
                                      String artifactVersion, Properties confOptions, File
reportsDirectory,
                                      String testMethodPattern )
     {
 
-        this.surefireDirectoryScanner = new DefaultDirectoryScanner( basedir, includes, excludes,
RunOrder.FILESYSTEM );
+        this.surefireDirectoryScanner = new DefaultDirectoryScanner( basedir, includes, excludes
);
+        this.runOrderCalculator = new DefaultRunOrderCalculator( RunOrder.FILESYSTEM );
 
         this.options = confOptions;
 
@@ -265,8 +270,10 @@ public class TestNGDirectoryTestSuite
         }
         testSets = new TreeMap();
 
-        final TestsToRun testsToRun =
+        final TestsToRun scanned =
             surefireDirectoryScanner.locateTestClasses( classLoader, new NonAbstractClassFilter()
);
+
+        final TestsToRun testsToRun = runOrderCalculator.orderTestClasses(  scanned );
         Class[] locatedClasses = testsToRun.getLocatedClasses();
 
         for ( int i = 0; i < locatedClasses.length; i++ )

Modified: maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java?rev=1203992&r1=1203991&r2=1203992&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java
(original)
+++ maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java
Sat Nov 19 15:30:02 2011
@@ -35,6 +35,7 @@ import org.apache.maven.surefire.testset
 import org.apache.maven.surefire.testset.TestSetFailedException;
 import org.apache.maven.surefire.util.DirectoryScanner;
 import org.apache.maven.surefire.util.NestedRuntimeException;
+import org.apache.maven.surefire.util.RunOrderCalculator;
 import org.apache.maven.surefire.util.TestsToRun;
 
 /**
@@ -64,11 +65,14 @@ public class TestNGProvider
 
     private final File basedir;
 
+    private final RunOrderCalculator runOrderCalculator;
+
     public TestNGProvider( ProviderParameters booterParameters )
     {
         this.providerParameters = booterParameters;
         this.testClassLoader = booterParameters.getTestClassLoader();
         this.directoryScannerParameters = booterParameters.getDirectoryScannerParameters();
+        this.runOrderCalculator = booterParameters.getRunOrderCalculator();
         this.providerProperties = booterParameters.getProviderProperties();
         this.testRequest = booterParameters.getTestRequest();
         basedir = directoryScannerParameters != null ? directoryScannerParameters.getTestClassesDirectory()
: null;
@@ -162,7 +166,8 @@ public class TestNGProvider
 
     private TestsToRun scanClassPath()
     {
-        return directoryScanner.locateTestClasses( testClassLoader, null );
+        final TestsToRun scanned = directoryScanner.locateTestClasses( testClassLoader, null
);
+        return runOrderCalculator.orderTestClasses(  scanned );
     }
 
 



Mime
View raw message