diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/api/testset/TestListResolver.java b/surefire-api/src/main/java/org/apache/maven/surefire/api/testset/TestListResolver.java index f8ebb1bdbc..37d0b1593b 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/api/testset/TestListResolver.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/api/testset/TestListResolver.java @@ -22,7 +22,9 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.LinkedHashSet; +import java.util.Map; import java.util.Set; import static java.util.Collections.unmodifiableSet; @@ -61,6 +63,8 @@ public class TestListResolver private final boolean hasExcludedMethodPatterns; + private final Map patternMapper = new HashMap(); + public TestListResolver( Collection tests ) { final IncludedExcludedPatterns patterns = new IncludedExcludedPatterns(); @@ -208,6 +212,7 @@ public boolean shouldRun( String testClassFile, String methodName ) else { boolean shouldRun = false; + ResolvedTest matchedFilter = null; if ( getIncludedPatterns().isEmpty() ) { @@ -220,6 +225,7 @@ public boolean shouldRun( String testClassFile, String methodName ) if ( filter.matchAsInclusive( testClassFile, methodName ) ) { shouldRun = true; + matchedFilter = filter; break; } } @@ -236,6 +242,15 @@ public boolean shouldRun( String testClassFile, String methodName ) } } } + + if ( shouldRun ) + { + String test = testClassFile + "#" + methodName; + if ( ! this.patternMapper.containsKey( test ) ) + { + this.patternMapper.put( test, new ArrayList<>( this.includedPatterns ).indexOf( matchedFilter ) ); + } + } return shouldRun; } } @@ -514,4 +529,24 @@ private static boolean haveMethodPatterns( Set patterns ) } return false; } + + public Integer testOrderComparator( String className1, String className2, String methodName1, String methodName2 ) + { + String classFileName1 = toClassFileName( className1 ); + String classFileName2 = toClassFileName( className2 ); + boolean shouldRunMethodName1 = shouldRun( classFileName1 , methodName1 ); + boolean shouldRunMethodName2 = shouldRun( classFileName2 , methodName2 ); + if ( ! shouldRunMethodName1 ) + { + return -1; + } + if ( ! shouldRunMethodName2 ) + { + return 1; + } + + String test1 = classFileName1 + "#" + methodName1; + String test2 = classFileName2 + "#" + methodName2; + return patternMapper.get( test1 ) - patternMapper.get( test2 ); + } } diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/api/util/DefaultRunOrderCalculator.java b/surefire-api/src/main/java/org/apache/maven/surefire/api/util/DefaultRunOrderCalculator.java index 8ced06afa5..6a06a99b8d 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/api/util/DefaultRunOrderCalculator.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/api/util/DefaultRunOrderCalculator.java @@ -21,8 +21,10 @@ import org.apache.maven.surefire.api.runorder.RunEntryStatisticsMap; import org.apache.maven.surefire.api.testset.RunOrderParameters; +import org.apache.maven.surefire.api.testset.TestListResolver; import java.util.ArrayList; +import java.util.Arrays; import java.util.Calendar; import java.util.Collections; import java.util.Comparator; @@ -48,6 +50,8 @@ public class DefaultRunOrderCalculator private final Random random; + private final TestListResolver testListResolver; + public DefaultRunOrderCalculator( RunOrderParameters runOrderParameters, int threadCount ) { this.runOrderParameters = runOrderParameters; @@ -61,6 +65,14 @@ public DefaultRunOrderCalculator( RunOrderParameters runOrderParameters, int thr runOrderParameters.setRunOrderRandomSeed( runOrderRandomSeed ); } this.random = new Random( runOrderRandomSeed ); + if ( RunOrder.TESTORDER.equals( getRunOrderMethod() ) ) + { + this.testListResolver = getTestListResolver(); + } + else + { + this.testListResolver = null; + } } @Override @@ -78,9 +90,80 @@ public TestsToRun orderTestClasses( TestsToRun scannedClasses ) return new TestsToRun( new LinkedHashSet<>( result ) ); } + @Override + public Comparator comparatorForTestMethods() + { + RunOrder methodRunOrder = getRunOrderMethod(); + if ( RunOrder.TESTORDER.equals( methodRunOrder ) ) + { + return new Comparator() + { + @Override + public int compare( String o1, String o2 ) + { + String[] classAndMethod1 = getClassAndMethod( o1 ); + String className1 = classAndMethod1[0]; + String methodName1 = classAndMethod1[1]; + String[] classAndMethod2 = getClassAndMethod( o2 ); + String className2 = classAndMethod2[0]; + String methodName2 = classAndMethod2[1]; + return testListResolver.testOrderComparator( className1, className2, methodName1, methodName2 ); + } + }; + } + else + { + return null; + } + } + + public TestListResolver getTestListResolver() + { + String orderParam = System.getProperty( "test" ); + if ( orderParam == null ) + { + throw new IllegalStateException( "TestListResolver in RunOrderCalculator should be used only when " + + "system property -Dtest is set and runOrder is testorder" ); + } + return new TestListResolver( Arrays.asList( orderParam.split( "," ) ) ); + } + + public String[] getClassAndMethod( String request ) + { + String[] classAndMethod = { request, request }; + if ( request.contains( "(" ) ) + { + String[] nameSplit1 = request.split( "\\(" ); + classAndMethod[0] = nameSplit1[1].substring( 0, nameSplit1[1].length() - 1 ); + classAndMethod[1] = nameSplit1[0]; + } + return classAndMethod; + } + + private RunOrder getRunOrderMethod() + { + if ( runOrder.length > 1 && Arrays.asList( runOrder ).contains( RunOrder.TESTORDER ) ) + { + // Use of testorder and other runOrders are currently not supported + throw new IllegalStateException( "Expected only testorder. Got: " + runOrder.length ); + } + return runOrder[0]; + } + private void orderTestClasses( List> testClasses, RunOrder runOrder ) { - if ( RunOrder.RANDOM.equals( runOrder ) ) + if ( RunOrder.TESTORDER.equals( runOrder ) ) + { + Collections.sort( testClasses, new Comparator>() + { + @Override + public int compare( Class o1, Class o2 ) + { + return testListResolver.testOrderComparator( o1.getName(), o2.getName(), null, null ); + } + } ); + } + else if ( RunOrder.RANDOM.equals( runOrder ) ) { Collections.shuffle( testClasses, random ); } diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/api/util/RunOrder.java b/surefire-api/src/main/java/org/apache/maven/surefire/api/util/RunOrder.java index b0d938266a..2d979a9513 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/api/util/RunOrder.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/api/util/RunOrder.java @@ -44,6 +44,8 @@ public class RunOrder public static final RunOrder FAILEDFIRST = new RunOrder( "failedfirst" ); + public static final RunOrder TESTORDER = new RunOrder( "testorder" ); + public static final RunOrder[] DEFAULT = new RunOrder[]{ FILESYSTEM }; /** @@ -108,7 +110,8 @@ private static String createMessageForMissingRunOrder( String name ) private static RunOrder[] values() { - return new RunOrder[]{ ALPHABETICAL, FILESYSTEM, HOURLY, RANDOM, REVERSE_ALPHABETICAL, BALANCED, FAILEDFIRST }; + return new RunOrder[]{ ALPHABETICAL, FILESYSTEM, HOURLY, RANDOM, REVERSE_ALPHABETICAL, BALANCED, FAILEDFIRST, + TESTORDER }; } public static String asString( RunOrder[] runOrder ) diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/api/util/RunOrderCalculator.java b/surefire-api/src/main/java/org/apache/maven/surefire/api/util/RunOrderCalculator.java index a9f99939ed..2c58002089 100644 --- a/surefire-api/src/main/java/org/apache/maven/surefire/api/util/RunOrderCalculator.java +++ b/surefire-api/src/main/java/org/apache/maven/surefire/api/util/RunOrderCalculator.java @@ -19,10 +19,14 @@ * under the License. */ +import java.util.Comparator; + /** * @author Kristian Rosenvold */ public interface RunOrderCalculator { TestsToRun orderTestClasses( TestsToRun scannedClasses ); + + Comparator comparatorForTestMethods(); } diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/api/testset/TestListResolverTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/api/testset/TestListResolverTest.java index 8ca9753a45..a123df1e1b 100644 --- a/surefire-api/src/test/java/org/apache/maven/surefire/api/testset/TestListResolverTest.java +++ b/surefire-api/src/test/java/org/apache/maven/surefire/api/testset/TestListResolverTest.java @@ -27,6 +27,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashSet; +import java.util.List; import java.util.Set; import static java.util.Collections.addAll; @@ -502,4 +503,68 @@ private static Set resolveClass( String patterns ) } return resolved; } + + public void testOrderComparatorTest() + { + List orderParamList = new ArrayList(); + orderParamList.add( "TestClass1#testa2d" ); + orderParamList.add( "TestClass1#testabc" ); + orderParamList.add( "TestClass1#testa1b" ); + orderParamList.add( "TestClass2#testa1b" ); + orderParamList.add( "TestClass2#testaBc" ); + TestListResolver tlr = new TestListResolver( orderParamList ); + String className = "TestClass1"; + String className2 = "TestClass2"; + assertTrue( ( int ) tlr.testOrderComparator( className, className, "testa2d", "testa1b" ) < 0 ); + assertTrue( ( int ) tlr.testOrderComparator( className, className, "testa2d", "testabc" ) < 0 ); + assertTrue( ( int ) tlr.testOrderComparator( className, className, "testa1b", "testabc" ) > 0 ); + assertTrue( ( int ) tlr.testOrderComparator( className, className, "testa2d", "testaBc" ) > 0 ); + assertTrue( ( int ) tlr.testOrderComparator( className, className, "testa3d", "testa1b" ) < 0 ); + assertTrue( ( int ) tlr.testOrderComparator( className, className2, "testa2d", "testa1b" ) < 0 ); + assertTrue( ( int ) tlr.testOrderComparator( className2, className, "testaBc", "testa1b" ) > 0 ); + assertTrue( ( int ) tlr.testOrderComparator( className, className2, "testa3d", "testa1b" ) < 0 ); + assertTrue( ( int ) tlr.testOrderComparator( className, className2, "testa2d", "testabc" ) > 0 ); + assertTrue( ( int ) tlr.testOrderComparator( className, className, "testa2d", "testa2d" ) == 0 ); + } + + public void testRegexMethodOrderComparator() + { + List orderParamList = new ArrayList(); + orderParamList.add( "TestClass1#testa?c" ); + orderParamList.add( "TestClass1#testa?b" ); + orderParamList.add( "TestClass2#test?1*" ); + orderParamList.add( "!TestClass1#testa4b" ); + orderParamList.add( "!TestClass2#test11MyTest" ); + TestListResolver tlr = new TestListResolver( orderParamList ); + String className = "TestClass1"; + String className2 = "TestClass2"; + assertTrue( ( int ) tlr.testOrderComparator( className, className, "testabc", "testa1b" ) < 0 ); + assertTrue( ( int ) tlr.testOrderComparator( className, className, "testaBc", "testa2b" ) < 0 ); + assertTrue( ( int ) tlr.testOrderComparator( className, className, "testa1b", "testa3c" ) > 0 ); + assertTrue( ( int ) tlr.testOrderComparator( className, className, "testa1b", "testa4b" ) > 0 ); + assertTrue( ( int ) tlr.testOrderComparator( className, className, "testa4b", "testabc" ) < 0 ); + assertTrue( ( int ) tlr.testOrderComparator( className, className2, "testa1b", "test1123" ) < 0 ); + assertTrue( ( int ) tlr.testOrderComparator( className2, className, "testa1b", "testa1b" ) > 0 ); + assertTrue( ( int ) tlr.testOrderComparator( className2, className2, "testa1b", "test1123" ) == 0 ); + assertTrue( ( int ) tlr.testOrderComparator( className2, className2, "test1123", "test11MyTest" ) > 0 ); + assertTrue( ( int ) tlr.testOrderComparator( className2, className2, "test11MyTest", "test456" ) < 0 ); + assertTrue( ( int ) tlr.testOrderComparator( className, className, "testa1c", "testa1c" ) == 0 ); + } + + public void testRegexClassOrderComparator() + { + List orderParamList = new ArrayList(); + orderParamList.add( "My2*Test.java" ); + orderParamList.add( "???My1*Test" ); + orderParamList.add( "!abcMy1PeaceTest" ); + TestListResolver tlr = new TestListResolver( orderParamList ); + String className = "My2ConnectTest"; + String className2 = "456My1ConnectTest"; + String className3 = "abcMy1PeaceTest"; + assertTrue( ( int ) tlr.testOrderComparator( className, className2, null, null ) < 0 ); + assertTrue( ( int ) tlr.testOrderComparator( className2, className, null, null ) > 0 ); + assertTrue( ( int ) tlr.testOrderComparator( className3, className2, null, null ) < 0 ); + assertTrue( ( int ) tlr.testOrderComparator( className, className3, null, null ) > 0 ); + assertTrue( ( int ) tlr.testOrderComparator( className, className, null, null ) == 0 ); + } } diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/api/util/RunOrderCalculatorTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/api/util/RunOrderCalculatorTest.java index 63768cf03d..e8f7d1cdc5 100644 --- a/surefire-api/src/test/java/org/apache/maven/surefire/api/util/RunOrderCalculatorTest.java +++ b/surefire-api/src/test/java/org/apache/maven/surefire/api/util/RunOrderCalculatorTest.java @@ -19,7 +19,10 @@ * under the License. */ +import java.util.Arrays; +import java.util.Comparator; import java.util.LinkedHashSet; +import java.util.List; import java.util.Set; import org.apache.maven.surefire.api.testset.RunOrderParameters; @@ -59,4 +62,52 @@ static class B { } + + public void testOrderTestMethods() + { + RunOrderParameters runOrderParameters = new RunOrderParameters( "testorder" , null ); + System.setProperty( "test", "TestClass#a2d,TestClass#aBc,TestClass#abc,TestClass#a1b" ); + DefaultRunOrderCalculator runOrderCalculator = new DefaultRunOrderCalculator( runOrderParameters, 1 ); + Comparator testOrderRunOrderComparator = runOrderCalculator.comparatorForTestMethods(); + String[] strArray = { "abc(TestClass)", "a1b(TestClass)", "a2d(TestClass)", "aBc(TestClass)" }; + List actual = Arrays.asList( strArray ); + actual.sort( testOrderRunOrderComparator ); + String[] strArray2 = { "a2d(TestClass)", "aBc(TestClass)", "abc(TestClass)", "a1b(TestClass)" }; + List expected = Arrays.asList( strArray2 ); + assertEquals( actual, expected ); + } + + public void testOrderTestClassesAndMethods() + { + RunOrderParameters runOrderParameters = new RunOrderParameters( "testorder" , null ); + System.setProperty( "test", "TestClass1#a2d,TestClass2#aBc,TestClass2#abc,TestClass2#a1b" ); + DefaultRunOrderCalculator runOrderCalculator = new DefaultRunOrderCalculator( runOrderParameters, 1 ); + Comparator testOrderRunOrderComparator = runOrderCalculator.comparatorForTestMethods(); + String[] strArray = { "abc(TestClass2)", "a1b(TestClass2)", "a2d(TestClass1)", "aBc(TestClass2)" }; + List actual = Arrays.asList( strArray ); + actual.sort( testOrderRunOrderComparator ); + String[] strArray2 = { "a2d(TestClass1)", "aBc(TestClass2)", "abc(TestClass2)", "a1b(TestClass2)" }; + List expected = Arrays.asList( strArray2 ); + assertEquals( actual, expected ); + } + + public void testOrderTestRegexClassesAndMethods() + { + RunOrderParameters runOrderParameters = new RunOrderParameters( "testorder" , null ); + System.setProperty( "test", "Amber*Test#a?c,My???Test#test*" ); + DefaultRunOrderCalculator runOrderCalculator = new DefaultRunOrderCalculator( runOrderParameters, 1 ); + Comparator testOrderRunOrderComparator = runOrderCalculator.comparatorForTestMethods(); + String[] strArray = { "abc(AmberGoodTest)", + "testabc(MyabcTest)", + "a2c(AmberBadTest)", + "testefg(MyefgTest)", + "aBc(AmberGoodTest)" }; + List actual = Arrays.asList( strArray ); + actual.sort( testOrderRunOrderComparator ); + assertEquals( runOrderCalculator.getClassAndMethod( actual.get( 0 ) )[0].substring( 0, 5 ), "Amber" ); + assertEquals( runOrderCalculator.getClassAndMethod( actual.get( 1 ) )[0].substring( 0, 5 ), "Amber" ); + assertEquals( runOrderCalculator.getClassAndMethod( actual.get( 2 ) )[0].substring( 0, 5 ), "Amber" ); + assertEquals( runOrderCalculator.getClassAndMethod( actual.get( 3 ) )[0].substring( 0, 2 ), "My" ); + assertEquals( runOrderCalculator.getClassAndMethod( actual.get( 4 ) )[0].substring( 0, 2 ), "My" ); + } } 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 3f4b095b76..7b345820f1 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 @@ -48,6 +48,7 @@ import org.junit.runner.notification.StoppedByUserException; import java.util.Collection; +import java.util.Comparator; import java.util.Set; import static java.lang.reflect.Modifier.isAbstract; @@ -269,7 +270,8 @@ private void executeWithRerun( Class clazz, Notifier notifier ) try { notifier.asFailFast( isFailFast() ); - execute( clazz, notifier, hasMethodFilter ? createMethodFilter() : null ); + execute( clazz, notifier, hasMethodFilter ? createMethodFilter() : null, + runOrderCalculator.comparatorForTestMethods() ); } finally { @@ -286,7 +288,8 @@ private void executeWithRerun( Class clazz, Notifier notifier ) Set failures = generateFailingTestDescriptions( failureListener.getAllFailures() ); failureListener.reset(); Filter failureDescriptionFilter = createMatchAnyDescriptionFilter( failures ); - execute( clazz, rerunNotifier, failureDescriptionFilter ); + execute( clazz, rerunNotifier, failureDescriptionFilter, + runOrderCalculator.comparatorForTestMethods() ); } } } @@ -348,12 +351,24 @@ private static boolean isJUnit4UpgradeCheck() return System.getProperty( "surefire.junit4.upgradecheck" ) != null; } - private static void execute( Class testClass, Notifier notifier, Filter filter ) + private static void execute( Class testClass, Notifier notifier, Filter filter, + final Comparator runOrderComparator ) { final int classModifiers = testClass.getModifiers(); if ( !isAbstract( classModifiers ) && !isInterface( classModifiers ) ) { Request request = aClass( testClass ); + if ( runOrderComparator != null ) + { + request = request.sortWith( new Comparator() + { + @Override + public int compare( Description o1, Description o2 ) + { + return runOrderComparator.compare( o1.toString(), o2.toString() ); + } + } ); + } if ( filter != null ) { request = request.filterWith( filter ); 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 6877b00b28..e842c712d0 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 @@ -145,7 +145,8 @@ public RunResult invoke( Object forkTestSet ) try { - JUnitCoreWrapper core = new JUnitCoreWrapper( notifier, jUnitCoreParameters, consoleStream ); + JUnitCoreWrapper core = new JUnitCoreWrapper( notifier, jUnitCoreParameters, consoleStream, + runOrderCalculator ); if ( commandsReader != null ) { @@ -162,7 +163,8 @@ public RunResult invoke( Object forkTestSet ) { Notifier rerunNotifier = pureNotifier(); notifier.copyListenersTo( rerunNotifier ); - JUnitCoreWrapper rerunCore = new JUnitCoreWrapper( rerunNotifier, jUnitCoreParameters, consoleStream ); + JUnitCoreWrapper rerunCore = new JUnitCoreWrapper( rerunNotifier, jUnitCoreParameters, consoleStream, + runOrderCalculator ); for ( int i = 0; i < rerunFailingTestsCount && !testFailureListener.getAllFailures().isEmpty(); i++ ) { Set failures = generateFailingTestDescriptions( testFailureListener.getAllFailures() ); diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java index 60ba4708bb..bf45ba5357 100644 --- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java +++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java @@ -24,6 +24,7 @@ import org.apache.maven.surefire.junitcore.pc.ParallelComputerBuilder; import org.apache.maven.surefire.api.report.ConsoleStream; import org.apache.maven.surefire.api.testset.TestSetFailedException; +import org.apache.maven.surefire.api.util.RunOrderCalculator; import org.apache.maven.surefire.api.util.TestsToRun; import org.junit.Ignore; import org.junit.runner.Computer; @@ -36,6 +37,7 @@ import java.util.Collection; import java.util.Collections; +import java.util.Comparator; import java.util.Iterator; import java.util.Queue; @@ -55,12 +57,15 @@ final class JUnitCoreWrapper private final Notifier notifier; private final JUnitCoreParameters jUnitCoreParameters; private final ConsoleStream consoleStream; + private final RunOrderCalculator runOrderCalculator; - JUnitCoreWrapper( Notifier notifier, JUnitCoreParameters jUnitCoreParameters, ConsoleStream consoleStream ) + JUnitCoreWrapper( Notifier notifier, JUnitCoreParameters jUnitCoreParameters, ConsoleStream consoleStream, + RunOrderCalculator runOrderCalculator ) { this.notifier = notifier; this.jUnitCoreParameters = jUnitCoreParameters; this.consoleStream = consoleStream; + this.runOrderCalculator = runOrderCalculator; } void execute( TestsToRun testsToRun, Filter filter ) @@ -124,6 +129,18 @@ private void createRequestAndRun( Filter filter, Computer computer, JUnitCore ju throws TestSetFailedException { Request req = classes( computer, classesToRun ); + final Comparator testOrderComparator = runOrderCalculator.comparatorForTestMethods(); + if ( testOrderComparator != null ) + { + req = req.sortWith( new Comparator() + { + @Override + public int compare( Description o1, Description o2 ) + { + return testOrderComparator.compare( o1.toString(), o2.toString() ); + } + } ); + } if ( filter != null ) { req = new FilteringRequest( req, filter ); diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java index 38690ae156..b5e677de74 100644 --- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java +++ b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java @@ -53,7 +53,9 @@ import org.apache.maven.surefire.api.report.ReporterFactory; import org.apache.maven.surefire.api.report.RunListener; import org.apache.maven.surefire.api.suite.RunResult; +import org.apache.maven.surefire.api.testset.RunOrderParameters; import org.apache.maven.surefire.api.testset.TestSetFailedException; +import org.apache.maven.surefire.api.util.DefaultRunOrderCalculator; import org.apache.maven.surefire.api.util.TestsToRun; import org.junit.Rule; @@ -137,7 +139,9 @@ public void surefireIsConfused_ByMultipleIgnore_OnClassLevel() throws Exception exception.expect( TestSetFailedException.class ); JUnit4RunListener dummy = new JUnit4RunListener( new MockReporter() ); new JUnitCoreWrapper( new Notifier( dummy, 0 ), jUnitCoreParameters, - new DefaultDirectConsoleReporter( System.out ) ).execute( testsToRun, customRunListeners, null ); + new DefaultDirectConsoleReporter( System.out ), + new DefaultRunOrderCalculator( RunOrderParameters.alphabetical(), 1 ) ). + execute( testsToRun, customRunListeners, null ); } finally {