diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java index b9daaa6fd1..37a05ca600 100644 --- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java +++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java @@ -185,7 +185,8 @@ public class IntegrationTestMojo * Each include item may also contain a comma-separated sublist of items, which will be treated as multiple *  <include> entries.
* Since 2.19 a complex syntax is supported in one parameter (JUnit 4, JUnit 4.7+, TestNG):
- *  <include>%regex[.*[Cat|Dog].*], !%regex[pkg.*Slow.*.class], pkg/**/*Fast*.java, Basic????, !Unstable*</include>
+ *  <include>%regex[.*[Cat|Dog].*], Basic????, !Unstable*</include>
+ *  <include>%regex[.*[Cat|Dog].*], !%regex[pkg.*Slow.*.class], pkg/**/*Fast*.java</include>
*

* This parameter is ignored if the TestNG suiteXmlFiles parameter is specified.
*
diff --git a/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java b/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java index 8d45d616a8..db9c482cd3 100644 --- a/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java +++ b/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java @@ -166,7 +166,8 @@ public class SurefirePlugin * Each include item may also contain a comma-separated sublist of items, which will be treated as multiple *  <include> entries.
* Since 2.19 a complex syntax is supported in one parameter (JUnit 4, JUnit 4.7+, TestNG):
- *  <include>%regex[.*[Cat|Dog].*], !%regex[pkg.*Slow.*.class], pkg/**/*Fast*.java, Basic????, !Unstable*</include>
+ *  <include>%regex[.*[Cat|Dog].*], Basic????, !Unstable*</include>
+ *  <include>%regex[.*[Cat|Dog].*], !%regex[pkg.*Slow.*.class], pkg/**/*Fast*.java</include>
*

* This parameter is ignored if the TestNG suiteXmlFiles parameter is specified.
*
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestMethodPatternIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestMethodPatternIT.java index 2fb082ef43..befae1b9a9 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestMethodPatternIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestMethodPatternIT.java @@ -21,6 +21,7 @@ import org.apache.maven.surefire.its.fixture.OutputValidator; import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; /** @@ -33,9 +34,14 @@ public class TestMethodPatternIT { private static final String RUNNING_WITH_JUNIT48 = "parallel='none', perCoreThreadCount=true, threadCount=0"; - public OutputValidator runMethodPattern( String projectName ) + public OutputValidator runMethodPattern( String projectName, String... goals ) { - return unpack( projectName ).executeTest().assertTestSuiteResults( 2, 0, 0, 0 ); + SurefireLauncher launcher = unpack( projectName ); + for ( String goal : goals ) + { + launcher.addGoal( goal ); + } + return launcher.executeTest().assertTestSuiteResults( 2, 0, 0, 0 ); } @Test @@ -45,15 +51,25 @@ public void testJUnit44() } @Test - public void testJUnit48() + public void testJUnit48Provider4() { - runMethodPattern( "junit48-method-pattern" ).verifyTextInLog( RUNNING_WITH_JUNIT48 ); + runMethodPattern( "junit48-method-pattern", "-P surefire-junit4" ); + } + + @Test + public void testJUnit48Provider47() + { + runMethodPattern( "junit48-method-pattern", "-P surefire-junit47" ) + .verifyTextInLog( RUNNING_WITH_JUNIT48 ); } @Test public void testJUnit48WithCategoryFilter() { - unpack( "junit48-method-pattern" ).addGoal( "-Dgroups=junit4.SampleCategory" ).executeTest().assertTestSuiteResults( 1, 0, 0, 0 );; + unpack( "junit48-method-pattern" ) + .addGoal( "-Dgroups=junit4.SampleCategory" ) + .executeTest() + .assertTestSuiteResults( 1, 0, 0, 0 );; } @Test @@ -71,7 +87,10 @@ public void testTestNGMethodPattern() @Test public void testMethodPatternAfter() { - unpack( "testng-method-pattern-after" ).executeTest().verifyErrorFree( 2 ).verifyTextInLog( "Called tearDown" ); + unpack( "testng-method-pattern-after" ) + .executeTest() + .verifyErrorFree( 2 ) + .verifyTextInLog( "Called tearDown" ); } } diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestMultipleMethodsIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestMultipleMethodsIT.java index 4b7dc35cbf..760b330cb6 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestMultipleMethodsIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestMultipleMethodsIT.java @@ -21,6 +21,7 @@ import org.apache.maven.surefire.its.fixture.OutputValidator; import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; @@ -35,10 +36,15 @@ public class TestMultipleMethodsIT private static final String RUNNING_WITH_JUNIT48 = "parallel='none', perCoreThreadCount=true, threadCount=0"; - public OutputValidator multipleMethod( String projectName ) + public OutputValidator multipleMethod( String projectName, String... goals ) throws Exception { - return unpack( projectName ).executeTest().verifyErrorFreeLog().assertTestSuiteResults( 3, 0, 0, 0 ); + SurefireLauncher launcher = unpack( projectName ); + for ( String goal : goals ) + { + launcher.addGoal( goal ); + } + return launcher.executeTest().verifyErrorFreeLog().assertTestSuiteResults( 3, 0, 0, 0 ); } @Test @@ -49,10 +55,18 @@ public void testJunit44() } @Test - public void testJunit48() + public void testJunit48Provider4() throws Exception { - multipleMethod( "junit48-multiple-methods" ).verifyTextInLog( RUNNING_WITH_JUNIT48 ); + multipleMethod( "junit48-multiple-methods", "-P surefire-junit4" ); + } + + @Test + public void testJunit48Provider47() + throws Exception + { + multipleMethod( "junit48-multiple-methods", "-P surefire-junit47" ) + .verifyTextInLog( RUNNING_WITH_JUNIT48 ); } } diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestSingleMethodIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestSingleMethodIT.java index 34b52a580f..b29064a4ca 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestSingleMethodIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestSingleMethodIT.java @@ -21,6 +21,7 @@ import org.apache.maven.surefire.its.fixture.OutputValidator; import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.apache.maven.surefire.its.fixture.SurefireLauncher; import org.junit.Test; /** @@ -33,10 +34,15 @@ public class TestSingleMethodIT { private static final String RUNNING_WITH_JUNIT48 = "parallel='none', perCoreThreadCount=true, threadCount=0"; - public OutputValidator singleMethod( String projectName ) + public OutputValidator singleMethod( String projectName, String... goals ) throws Exception { - return unpack( projectName ).executeTest().verifyErrorFreeLog().assertTestSuiteResults( 1, 0, 0, 0 ); + SurefireLauncher launcher = unpack( projectName ); + for ( String goal : goals ) + { + launcher.addGoal( goal ); + } + return launcher.executeTest().verifyErrorFreeLog().assertTestSuiteResults( 1, 0, 0, 0 ); } @Test @@ -47,10 +53,18 @@ public void testJunit44() } @Test - public void testJunit48() + public void testJunit48Provider4() throws Exception { - singleMethod( "junit48-single-method" ).verifyTextInLog( RUNNING_WITH_JUNIT48 ); + singleMethod( "junit48-single-method", "-P surefire-junit4" ); + } + + @Test + public void testJunit48Provider47() + throws Exception + { + singleMethod( "junit48-single-method", "-P surefire-junit47" ) + .verifyTextInLog( RUNNING_WITH_JUNIT48 ); } @Test @@ -58,9 +72,11 @@ public void testJunit48parallel() throws Exception { unpack( "junit48-single-method" ) - .executeTest() - .verifyErrorFreeLog() - .assertTestSuiteResults( 1, 0, 0, 0 ); + .parallel( "all" ) + .useUnlimitedThreads() + .executeTest() + .verifyErrorFreeLog() + .assertTestSuiteResults( 1, 0, 0, 0 ); } @Test diff --git a/surefire-integration-tests/src/test/resources/junit48-method-pattern/pom.xml b/surefire-integration-tests/src/test/resources/junit48-method-pattern/pom.xml index 40172208aa..fe1690cdd2 100644 --- a/surefire-integration-tests/src/test/resources/junit48-method-pattern/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit48-method-pattern/pom.xml @@ -23,12 +23,18 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 + + org.apache.maven.surefire + it-parent + 1.0 + ../pom.xml + + org.apache.maven.plugins.surefire junit4 1.0-SNAPSHOT Test for JUnit 4.8.1 - 4.8.1 @@ -55,19 +61,51 @@ org.apache.maven.plugins maven-surefire-plugin - ${surefire.version} BasicTest#testSuccess* + once - - - org.apache.maven.surefire - surefire-junit47 - ${surefire.version} - - + + + surefire-junit47 + + + + org.apache.maven.plugins + maven-surefire-plugin + + + org.apache.maven.surefire + surefire-junit47 + ${surefire.version} + + + + + + + + surefire-junit4 + + + + org.apache.maven.plugins + maven-surefire-plugin + + + org.apache.maven.surefire + surefire-junit4 + ${surefire.version} + + + + + + + + diff --git a/surefire-integration-tests/src/test/resources/junit48-multiple-methods/pom.xml b/surefire-integration-tests/src/test/resources/junit48-multiple-methods/pom.xml index 635acb7ea3..83b3044c85 100644 --- a/surefire-integration-tests/src/test/resources/junit48-multiple-methods/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit48-multiple-methods/pom.xml @@ -35,7 +35,6 @@ 1.0-SNAPSHOT Test for JUnit 4.8.1 - 4.8.1 @@ -64,16 +63,49 @@ maven-surefire-plugin junit4/BasicTest#testSuccessOne+testFailOne,junit4/TestThree#testSuccessTwo + once - - - org.apache.maven.surefire - surefire-junit47 - ${surefire.version} - - + + + surefire-junit47 + + + + org.apache.maven.plugins + maven-surefire-plugin + + + org.apache.maven.surefire + surefire-junit47 + ${surefire.version} + + + + + + + + surefire-junit4 + + + + org.apache.maven.plugins + maven-surefire-plugin + + + org.apache.maven.surefire + surefire-junit4 + ${surefire.version} + + + + + + + + diff --git a/surefire-integration-tests/src/test/resources/junit48-single-method/pom.xml b/surefire-integration-tests/src/test/resources/junit48-single-method/pom.xml index ae544d1340..ff701a3bfd 100644 --- a/surefire-integration-tests/src/test/resources/junit48-single-method/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit48-single-method/pom.xml @@ -23,12 +23,18 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 + + org.apache.maven.surefire + it-parent + 1.0 + ../pom.xml + + org.apache.maven.plugins.surefire junit4 1.0-SNAPSHOT Test for JUnit 4.8.1 - 4.8.1 @@ -55,19 +61,51 @@ org.apache.maven.plugins maven-surefire-plugin - ${surefire.version} BasicTest#testSuccessOne + once - - - org.apache.maven.surefire - surefire-junit47 - ${surefire.version} - - + + + surefire-junit47 + + + + org.apache.maven.plugins + maven-surefire-plugin + + + org.apache.maven.surefire + surefire-junit47 + ${surefire.version} + + + + + + + + surefire-junit4 + + + + org.apache.maven.plugins + maven-surefire-plugin + + + org.apache.maven.surefire + surefire-junit4 + ${surefire.version} + + + + + + + +