[SUREFIRE-745][SUREFIRE-1126]

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

Branch: refs/heads/master
Commit: 947abde38a101b028deabf0316d5efa44dd074b7
Parents: 866a535
Author: Tibor17 <tibo...@lycos.com>
Authored: Wed Mar 25 00:47:56 2015 +0100
Committer: Tibor17 <tibo...@lycos.com>
Committed: Wed Mar 25 00:47:56 2015 +0100

----------------------------------------------------------------------
 .../plugin/failsafe/IntegrationTestMojo.java    |  3 +-
 .../maven/plugin/surefire/SurefirePlugin.java   |  3 +-
 .../maven/surefire/its/TestMethodPatternIT.java | 31 ++++++++---
 .../surefire/its/TestMultipleMethodsIT.java     | 22 ++++++--
 .../maven/surefire/its/TestSingleMethodIT.java  | 30 ++++++++---
 .../resources/junit48-method-pattern/pom.xml    | 56 ++++++++++++++++----
 .../resources/junit48-multiple-methods/pom.xml  | 48 ++++++++++++++---
 .../resources/junit48-single-method/pom.xml     | 56 ++++++++++++++++----
 8 files changed, 204 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/947abde3/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
----------------------------------------------------------------------
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 b9daaa6..37a05ca 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
      * &nbsp;&lt;include> entries.<br/>
      * Since 2.19 a complex syntax is supported in one parameter (JUnit 4, 
JUnit 4.7+, TestNG):<br/>
-     * &nbsp;&lt;include>%regex[.*[Cat|Dog].*], !%regex[pkg.*Slow.*.class], 
pkg&#47;**&#47;*Fast*.java, Basic????, !Unstable*&lt;/include><br/>
+     * &nbsp;&lt;include>%regex[.*[Cat|Dog].*], Basic????, 
!Unstable*&lt;/include><br/>
+     * &nbsp;&lt;include>%regex[.*[Cat|Dog].*], !%regex[pkg.*Slow.*.class], 
pkg&#47;**&#47;*Fast*.java&lt;/include><br/>
      * <p/>
      * This parameter is ignored if the TestNG <code>suiteXmlFiles</code> 
parameter is specified.<br/>
      * <br/>

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/947abde3/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
----------------------------------------------------------------------
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 8d45d61..db9c482 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
      * &nbsp;&lt;include> entries.<br/>
      * Since 2.19 a complex syntax is supported in one parameter (JUnit 4, 
JUnit 4.7+, TestNG):<br/>
-     * &nbsp;&lt;include>%regex[.*[Cat|Dog].*], !%regex[pkg.*Slow.*.class], 
pkg&#47;**&#47;*Fast*.java, Basic????, !Unstable*&lt;/include><br/>
+     * &nbsp;&lt;include>%regex[.*[Cat|Dog].*], Basic????, 
!Unstable*&lt;/include><br/>
+     * &nbsp;&lt;include>%regex[.*[Cat|Dog].*], !%regex[pkg.*Slow.*.class], 
pkg&#47;**&#47;*Fast*.java&lt;/include><br/>
      * <p/>
      * This parameter is ignored if the TestNG <code>suiteXmlFiles</code> 
parameter is specified.<br/>
      * <br/>

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/947abde3/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestMethodPatternIT.java
----------------------------------------------------------------------
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 2fb082e..befae1b 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 @@ package org.apache.maven.surefire.its;
 
 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 class TestMethodPatternIT
     }
 
     @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 class TestMethodPatternIT
     @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" );
     }
 
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/947abde3/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestMultipleMethodsIT.java
----------------------------------------------------------------------
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 4b7dc35..760b330 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 @@ package org.apache.maven.surefire.its;
 
 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 class TestMultipleMethodsIT
     }
 
     @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 );
     }
 
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/947abde3/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestSingleMethodIT.java
----------------------------------------------------------------------
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 34b52a5..b29064a 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 @@ package org.apache.maven.surefire.its;
 
 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 class TestSingleMethodIT
     }
 
     @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 class TestSingleMethodIT
         throws Exception
     {
         unpack( "junit48-single-method" )
-                .executeTest()
-                .verifyErrorFreeLog()
-                .assertTestSuiteResults( 1, 0, 0, 0 );
+            .parallel( "all" )
+            .useUnlimitedThreads()
+            .executeTest()
+            .verifyErrorFreeLog()
+            .assertTestSuiteResults( 1, 0, 0, 0 );
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/947abde3/surefire-integration-tests/src/test/resources/junit48-method-pattern/pom.xml
----------------------------------------------------------------------
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 4017220..fe1690c 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";>
   <modelVersion>4.0.0</modelVersion>
 
+  <parent>
+    <groupId>org.apache.maven.surefire</groupId>
+    <artifactId>it-parent</artifactId>
+    <version>1.0</version>
+    <relativePath>../pom.xml</relativePath>
+  </parent>
+
   <groupId>org.apache.maven.plugins.surefire</groupId>
   <artifactId>junit4</artifactId>
   <version>1.0-SNAPSHOT</version>
   <name>Test for JUnit 4.8.1</name>
 
-
   <properties>
     <junitVersion>4.8.1</junitVersion>
   </properties>
@@ -55,19 +61,51 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-surefire-plugin</artifactId>
-        <version>${surefire.version}</version>
         <configuration>
           <test>BasicTest#testSuccess*</test>
+          <forkMode>once</forkMode>
         </configuration>
-        <dependencies>
-          <dependency>
-            <groupId>org.apache.maven.surefire</groupId>
-            <artifactId>surefire-junit47</artifactId>
-            <version>${surefire.version}</version>
-          </dependency>
-        </dependencies>
       </plugin>
     </plugins>
   </build>
 
+  <profiles>
+    <profile>
+      <id>surefire-junit47</id>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <dependencies>
+              <dependency>
+                <groupId>org.apache.maven.surefire</groupId>
+                <artifactId>surefire-junit47</artifactId>
+                <version>${surefire.version}</version>
+              </dependency>
+            </dependencies>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+    <profile>
+      <id>surefire-junit4</id>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <dependencies>
+              <dependency>
+                <groupId>org.apache.maven.surefire</groupId>
+                <artifactId>surefire-junit4</artifactId>
+                <version>${surefire.version}</version>
+              </dependency>
+            </dependencies>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+
 </project>

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/947abde3/surefire-integration-tests/src/test/resources/junit48-multiple-methods/pom.xml
----------------------------------------------------------------------
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 635acb7..83b3044 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 @@
   <version>1.0-SNAPSHOT</version>
   <name>Test for JUnit 4.8.1</name>
 
-
   <properties>
     <junitVersion>4.8.1</junitVersion>
   </properties>
@@ -64,16 +63,49 @@
         <artifactId>maven-surefire-plugin</artifactId>
         <configuration>
           
<test>junit4/BasicTest#testSuccessOne+testFailOne,junit4/TestThree#testSuccessTwo</test>
+          <forkMode>once</forkMode>
         </configuration>
-        <dependencies>
-          <dependency>
-            <groupId>org.apache.maven.surefire</groupId>
-            <artifactId>surefire-junit47</artifactId>
-            <version>${surefire.version}</version>
-          </dependency>
-        </dependencies>
       </plugin>
     </plugins>
   </build>
 
+  <profiles>
+    <profile>
+      <id>surefire-junit47</id>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <dependencies>
+              <dependency>
+                <groupId>org.apache.maven.surefire</groupId>
+                <artifactId>surefire-junit47</artifactId>
+                <version>${surefire.version}</version>
+              </dependency>
+            </dependencies>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+    <profile>
+      <id>surefire-junit4</id>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <dependencies>
+              <dependency>
+                <groupId>org.apache.maven.surefire</groupId>
+                <artifactId>surefire-junit4</artifactId>
+                <version>${surefire.version}</version>
+              </dependency>
+            </dependencies>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+
 </project>

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/947abde3/surefire-integration-tests/src/test/resources/junit48-single-method/pom.xml
----------------------------------------------------------------------
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 ae544d1..ff701a3 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";>
   <modelVersion>4.0.0</modelVersion>
 
+  <parent>
+    <groupId>org.apache.maven.surefire</groupId>
+    <artifactId>it-parent</artifactId>
+    <version>1.0</version>
+    <relativePath>../pom.xml</relativePath>
+  </parent>
+
   <groupId>org.apache.maven.plugins.surefire</groupId>
   <artifactId>junit4</artifactId>
   <version>1.0-SNAPSHOT</version>
   <name>Test for JUnit 4.8.1</name>
 
-
   <properties>
     <junitVersion>4.8.1</junitVersion>
   </properties>
@@ -55,19 +61,51 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-surefire-plugin</artifactId>
-        <version>${surefire.version}</version>
         <configuration>
           <test>BasicTest#testSuccessOne</test>
+          <forkMode>once</forkMode>
         </configuration>
-        <dependencies>
-          <dependency>
-            <groupId>org.apache.maven.surefire</groupId>
-            <artifactId>surefire-junit47</artifactId>
-            <version>${surefire.version}</version>
-          </dependency>
-        </dependencies>
       </plugin>
     </plugins>
   </build>
 
+  <profiles>
+    <profile>
+      <id>surefire-junit47</id>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <dependencies>
+              <dependency>
+                <groupId>org.apache.maven.surefire</groupId>
+                <artifactId>surefire-junit47</artifactId>
+                <version>${surefire.version}</version>
+              </dependency>
+            </dependencies>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+    <profile>
+      <id>surefire-junit4</id>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <dependencies>
+              <dependency>
+                <groupId>org.apache.maven.surefire</groupId>
+                <artifactId>surefire-junit4</artifactId>
+                <version>${surefire.version}</version>
+              </dependency>
+            </dependencies>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+
 </project>

Reply via email to