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 2020/04/16 23:02:07 UTC

[maven-surefire] branch pull/248 created (now 29dec2b)

This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a change to branch pull/248
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git.


      at 29dec2b  automated tests

This branch includes the following new commits:

     new 29dec2b  automated tests

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven-surefire] 01/01: automated tests

Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch pull/248
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git

commit 29dec2bde42b3f57b83c2c2a5af8262dba9bf33d
Author: tibordigana <ti...@apache.org>
AuthorDate: Fri Apr 17 01:01:58 2020 +0200

    automated tests
---
 surefire-providers/common-junit48/pom.xml          | 220 ++++++++++++++-------
 .../GroupMatcherCategoryFilterPreJUnit412Test.java |  45 +++--
 .../junit48/GroupMatcherCategoryFilterTest.java    |  61 ++++--
 3 files changed, 227 insertions(+), 99 deletions(-)

diff --git a/surefire-providers/common-junit48/pom.xml b/surefire-providers/common-junit48/pom.xml
index fa80e47..a011654 100644
--- a/surefire-providers/common-junit48/pom.xml
+++ b/surefire-providers/common-junit48/pom.xml
@@ -17,77 +17,161 @@
   ~ under the License.
   -->
 
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
 
-  <parent>
-    <groupId>org.apache.maven.surefire</groupId>
-    <artifactId>surefire-providers</artifactId>
-    <version>3.0.0-SNAPSHOT</version>
-  </parent>
+    <parent>
+        <groupId>org.apache.maven.surefire</groupId>
+        <artifactId>surefire-providers</artifactId>
+        <version>3.0.0-SNAPSHOT</version>
+    </parent>
 
-  <artifactId>common-junit48</artifactId>
+    <artifactId>common-junit48</artifactId>
 
-  <name>Shared JUnit48 Provider Code</name>
-  <description>Shared JUnit48 Provider Code</description>
+    <name>Shared JUnit48 Provider Code</name>
+    <description>Shared JUnit48 Provider Code</description>
 
-  <dependencies>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>4.8.1</version>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven.surefire</groupId>
-      <artifactId>common-junit4</artifactId>
-      <version>${project.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven.surefire</groupId>
-      <artifactId>surefire-grouper</artifactId>
-      <version>${project.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven.shared</groupId>
-      <artifactId>maven-shared-utils</artifactId>
-      <scope>test</scope>
-    </dependency>
-  </dependencies>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.jacoco</groupId>
-        <artifactId>jacoco-maven-plugin</artifactId>
-        <executions>
-          <execution>
-            <id>jacoco-agent</id>
-            <goals>
-              <goal>prepare-agent</goal>
-            </goals>
-          </execution>
-        </executions>
-        <configuration>
-          <propertyName>jacoco.agent</propertyName>
-        </configuration>
-      </plugin>
-      <plugin>
-        <artifactId>maven-surefire-plugin</artifactId>
-        <configuration>
-          <argLine>${jvm.args.tests} ${jacoco.agent}</argLine>
-          <includes>
-            <include>**/JUnit4SuiteTest.java</include>
-          </includes>
-        </configuration>
-        <dependencies>
-          <dependency>
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.8.1</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven.surefire</groupId>
+            <artifactId>common-junit4</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
             <groupId>org.apache.maven.surefire</groupId>
-            <artifactId>surefire-shadefire</artifactId>
-            <version>3.0.0-M4</version> <!-- ${shadedVersion}, but resolved due to https://issues.apache.org/jira/browse/MRELEASE-799 -->
-          </dependency>
-        </dependencies>
-      </plugin>
-    </plugins>
-  </build>
+            <artifactId>surefire-grouper</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven.shared</groupId>
+            <artifactId>maven-shared-utils</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.jacoco</groupId>
+                <artifactId>jacoco-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>jacoco-agent</id>
+                        <goals>
+                            <goal>prepare-agent</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <propertyName>jacoco.agent</propertyName>
+                </configuration>
+            </plugin>
+            <plugin>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>junit-4.11</id>
+                        <phase>process-test-sources</phase>
+                        <goals>
+                            <goal>copy</goal>
+                        </goals>
+                        <configuration>
+                            <outputDirectory>${project.build.directory}/endorsed-test</outputDirectory>
+                            <overWriteIfNewer>false</overWriteIfNewer>
+                            <artifactItems>
+                                <artifactItem>
+                                    <groupId>junit</groupId>
+                                    <artifactId>junit</artifactId>
+                                    <version>4.11</version>
+                                    <type>jar</type>
+                                </artifactItem>
+                            </artifactItems>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>test</id>
+                        <phase>process-test-sources</phase>
+                        <goals>
+                            <goal>copy</goal>
+                        </goals>
+                        <configuration>
+                            <outputDirectory>${project.build.directory}/endorsed-test</outputDirectory>
+                            <overWriteIfNewer>false</overWriteIfNewer>
+                            <artifactItems>
+                                <artifactItem>
+                                    <groupId>junit</groupId>
+                                    <artifactId>junit</artifactId>
+                                    <version>4.12</version>
+                                    <type>jar</type>
+                                </artifactItem>
+                            </artifactItems>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>default-test</id>
+                        <phase>test</phase>
+                        <goals>
+                            <goal>test</goal>
+                        </goals>
+                        <configuration>
+                            <includes>
+                                <include>**/JUnit4SuiteTest.java</include>
+                            </includes>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>junit-4.11</id>
+                        <phase>test</phase>
+                        <goals>
+                            <goal>test</goal>
+                        </goals>
+                        <configuration>
+                            <test>GroupMatcherCategoryFilterPreJUnit412Test$JUnit4SuiteTest</test>
+                            <classpathDependencyExcludes>junit:junit</classpathDependencyExcludes>
+                            <additionalClasspathElements>
+                                <additionalClasspathElement>${project.build.directory}/endorsed-test/junit-4.11.jar</additionalClasspathElement>
+                            </additionalClasspathElements>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>junit-4.12</id>
+                        <phase>test</phase>
+                        <goals>
+                            <goal>test</goal>
+                        </goals>
+                        <configuration>
+                            <test>GroupMatcherCategoryFilterTest$JUnit4SuiteTest</test>
+                            <classpathDependencyExcludes>junit:junit</classpathDependencyExcludes>
+                            <additionalClasspathElements>
+                                <additionalClasspathElement>${project.build.directory}/endorsed-test/junit-4.12.jar</additionalClasspathElement>
+                            </additionalClasspathElements>
+                        </configuration>
+                    </execution>
+                </executions>
+                <configuration>
+                    <argLine>${jvm.args.tests} ${jacoco.agent}</argLine>
+                </configuration>
+                <dependencies>
+                    <dependency>
+                        <groupId>org.apache.maven.surefire</groupId>
+                        <artifactId>surefire-shadefire</artifactId>
+                        <version>3.0.0-M4
+                        </version> <!-- ${shadedVersion}, but resolved due to https://issues.apache.org/jira/browse/MRELEASE-799 -->
+                    </dependency>
+                </dependencies>
+            </plugin>
+        </plugins>
+    </build>
 </project>
diff --git a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/GroupMatcherCategoryFilterPreJUnit412Test.java b/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/GroupMatcherCategoryFilterPreJUnit412Test.java
index 4df8abb..48458e0 100644
--- a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/GroupMatcherCategoryFilterPreJUnit412Test.java
+++ b/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/GroupMatcherCategoryFilterPreJUnit412Test.java
@@ -19,24 +19,36 @@ package org.apache.maven.surefire.common.junit48;
  * under the License.
  */
 
+import junit.framework.JUnit4TestAdapter;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.runner.Version;
 import org.apache.maven.surefire.common.junit48.tests.group.ABCParameterizedTest;
 import org.apache.maven.surefire.common.junit48.tests.group.ABCTest;
 import org.apache.maven.surefire.common.junit48.tests.group.ATest;
 import org.apache.maven.surefire.common.junit48.tests.group.BCTest;
 import org.apache.maven.surefire.group.match.GroupMatcher;
 import org.apache.maven.surefire.group.match.SingleGroupMatcher;
-import org.junit.Assert;
+import org.junit.BeforeClass;
 import org.junit.Test;
-import org.junit.runner.Description;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.runner.Description.createSuiteDescription;
+import static org.junit.runner.Description.createTestDescription;
 
 /**
  * Before JUnit 4.12, @Category annotation was not @Inherited. These tests make sure the implied contract is honored.
  */
 public class GroupMatcherCategoryFilterPreJUnit412Test
 {
-
     private GroupMatcherCategoryFilter cut;
 
+    @BeforeClass
+    public static void printVersion()
+    {
+        System.out.println( Version.id() );
+    }
+
     @Test
     public void shouldNotMatchIncludedCategoryInParent()
     {
@@ -44,8 +56,8 @@ public class GroupMatcherCategoryFilterPreJUnit412Test
             new SingleGroupMatcher( "org.apache.maven.surefire.common.junit48.tests.group.marker.CategoryB" );
         GroupMatcher excluded = null;
         cut = new GroupMatcherCategoryFilter( included, excluded );
-        Assert.assertFalse( cut.shouldRun( Description.createSuiteDescription( BCTest.class ) ) );
-        Assert.assertFalse( cut.shouldRun( Description.createSuiteDescription( ATest.class ) ) );
+        assertFalse( cut.shouldRun( createSuiteDescription( BCTest.class ) ) );
+        assertFalse( cut.shouldRun( createSuiteDescription( ATest.class ) ) );
     }
 
     @Test
@@ -55,9 +67,9 @@ public class GroupMatcherCategoryFilterPreJUnit412Test
             new SingleGroupMatcher( "org.apache.maven.surefire.common.junit48.tests.group.marker.CategoryC" );
         GroupMatcher excluded = null;
         cut = new GroupMatcherCategoryFilter( included, excluded );
-        Assert.assertFalse( cut.shouldRun( Description.createSuiteDescription( ABCTest.class ) ) );
-        Assert.assertFalse( cut.shouldRun( Description.createSuiteDescription( BCTest.class ) ) );
-        Assert.assertFalse( cut.shouldRun( Description.createSuiteDescription( ATest.class ) ) );
+        assertFalse( cut.shouldRun( createSuiteDescription( ABCTest.class ) ) );
+        assertFalse( cut.shouldRun( createSuiteDescription( BCTest.class ) ) );
+        assertFalse( cut.shouldRun( createSuiteDescription( ATest.class ) ) );
     }
 
     @Test
@@ -67,10 +79,19 @@ public class GroupMatcherCategoryFilterPreJUnit412Test
             new SingleGroupMatcher( "org.apache.maven.surefire.common.junit48.tests.group.marker.CategoryB" );
         GroupMatcher excluded = null;
         cut = new GroupMatcherCategoryFilter( included, excluded );
-        Assert.assertFalse( cut.shouldRun( Description.createSuiteDescription( ABCTest.class ) ) );
-        Assert.assertFalse( cut.shouldRun( Description.createTestDescription( ABCTest.class, "abc" ) ) );
-        Assert.assertFalse( cut.shouldRun( Description.createSuiteDescription( ABCParameterizedTest.class ) ) );
-        Assert.assertFalse( cut.shouldRun( Description.createTestDescription( ABCParameterizedTest.class, "abc" ) ) );
+        assertFalse( cut.shouldRun( createSuiteDescription( ABCTest.class ) ) );
+        assertFalse( cut.shouldRun( createTestDescription( ABCTest.class, "abc" ) ) );
+        assertFalse( cut.shouldRun( createSuiteDescription( ABCParameterizedTest.class ) ) );
+        assertFalse( cut.shouldRun( createTestDescription( ABCParameterizedTest.class, "abc" ) ) );
     }
 
+    public static class JUnit4SuiteTest extends TestCase
+    {
+        public static junit.framework.Test suite()
+        {
+            TestSuite suite = new TestSuite();
+            suite.addTest( new JUnit4TestAdapter( GroupMatcherCategoryFilterPreJUnit412Test.class ) );
+            return suite;
+        }
+    }
 }
diff --git a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/GroupMatcherCategoryFilterTest.java b/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/GroupMatcherCategoryFilterTest.java
index 6e4f8ef..98f6dc7 100644
--- a/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/GroupMatcherCategoryFilterTest.java
+++ b/surefire-providers/common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/GroupMatcherCategoryFilterTest.java
@@ -19,6 +19,10 @@ package org.apache.maven.surefire.common.junit48;
  * under the License.
  */
 
+import junit.framework.JUnit4TestAdapter;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.runner.Version;
 import org.apache.maven.surefire.common.junit48.tests.group.ABCParameterizedTest;
 import org.apache.maven.surefire.common.junit48.tests.group.ABCTest;
 import org.apache.maven.surefire.common.junit48.tests.group.ATest;
@@ -27,18 +31,27 @@ import org.apache.maven.surefire.common.junit48.tests.group.BCTest;
 import org.apache.maven.surefire.common.junit48.tests.group.BTest;
 import org.apache.maven.surefire.group.match.GroupMatcher;
 import org.apache.maven.surefire.group.match.SingleGroupMatcher;
-import org.junit.Assert;
+import org.junit.BeforeClass;
 import org.junit.Test;
-import org.junit.runner.Description;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.runner.Description.createSuiteDescription;
+import static org.junit.runner.Description.createTestDescription;
 
 /**
  * Tests covering inheritance in @Categories for Test classes.
  */
 public class GroupMatcherCategoryFilterTest
 {
-
     private GroupMatcherCategoryFilter cut;
 
+    @BeforeClass
+    public static void printVersion()
+    {
+        System.out.println( Version.id() );
+    }
+
     @Test
     public void shouldMatchIncludedCategoryInSelf()
     {
@@ -46,7 +59,7 @@ public class GroupMatcherCategoryFilterTest
             new SingleGroupMatcher( "org.apache.maven.surefire.common.junit48.tests.group.marker.CategoryB" );
         GroupMatcher excluded = null;
         cut = new GroupMatcherCategoryFilter( included, excluded );
-        Assert.assertTrue( cut.shouldRun( Description.createSuiteDescription( BTest.class ) ) );
+        assertTrue( cut.shouldRun( createSuiteDescription( BTest.class ) ) );
     }
 
     @Test
@@ -56,8 +69,8 @@ public class GroupMatcherCategoryFilterTest
             new SingleGroupMatcher( "org.apache.maven.surefire.common.junit48.tests.group.marker.CategoryB" );
         GroupMatcher excluded = null;
         cut = new GroupMatcherCategoryFilter( included, excluded );
-        Assert.assertTrue( cut.shouldRun( Description.createSuiteDescription( BCTest.class ) ) );
-        Assert.assertFalse( cut.shouldRun( Description.createSuiteDescription( ATest.class ) ) );
+        assertTrue( cut.shouldRun( createSuiteDescription( BCTest.class ) ) );
+        assertFalse( cut.shouldRun( createSuiteDescription( ATest.class ) ) );
     }
 
     @Test
@@ -67,9 +80,9 @@ public class GroupMatcherCategoryFilterTest
             new SingleGroupMatcher( "org.apache.maven.surefire.common.junit48.tests.group.marker.CategoryC" );
         GroupMatcher excluded = null;
         cut = new GroupMatcherCategoryFilter( included, excluded );
-        Assert.assertTrue( cut.shouldRun( Description.createSuiteDescription( ABCTest.class ) ) );
-        Assert.assertTrue( cut.shouldRun( Description.createSuiteDescription( BCTest.class ) ) );
-        Assert.assertFalse( cut.shouldRun( Description.createSuiteDescription( ATest.class ) ) );
+        assertTrue( cut.shouldRun( createSuiteDescription( ABCTest.class ) ) );
+        assertTrue( cut.shouldRun( createSuiteDescription( BCTest.class ) ) );
+        assertFalse( cut.shouldRun( createSuiteDescription( ATest.class ) ) );
     }
 
     @Test
@@ -79,10 +92,10 @@ public class GroupMatcherCategoryFilterTest
             new SingleGroupMatcher( "org.apache.maven.surefire.common.junit48.tests.group.marker.CategoryB" );
         GroupMatcher excluded = null;
         cut = new GroupMatcherCategoryFilter( included, excluded );
-        Assert.assertTrue( cut.shouldRun( Description.createSuiteDescription( ABCTest.class ) ) );
-        Assert.assertTrue( cut.shouldRun( Description.createTestDescription( ABCTest.class, "abc" ) ) );
-        Assert.assertTrue( cut.shouldRun( Description.createSuiteDescription( ABCParameterizedTest.class ) ) );
-        Assert.assertTrue( cut.shouldRun( Description.createTestDescription( ABCParameterizedTest.class, "abc" ) ) );
+        assertTrue( cut.shouldRun( createSuiteDescription( ABCTest.class ) ) );
+        assertTrue( cut.shouldRun( createTestDescription( ABCTest.class, "abc" ) ) );
+        assertTrue( cut.shouldRun( createSuiteDescription( ABCParameterizedTest.class ) ) );
+        assertTrue( cut.shouldRun( createTestDescription( ABCParameterizedTest.class, "abc" ) ) );
     }
 
     @Test
@@ -93,9 +106,9 @@ public class GroupMatcherCategoryFilterTest
         GroupMatcher excluded =
             new SingleGroupMatcher( "org.apache.maven.surefire.common.junit48.tests.group.marker.CategoryA" );
         cut = new GroupMatcherCategoryFilter( included, excluded );
-        Assert.assertFalse( cut.shouldRun( Description.createSuiteDescription( ABCTest.class ) ) );
-        Assert.assertTrue( cut.shouldRun( Description.createSuiteDescription( BBCTest.class ) ) );
-        Assert.assertTrue( cut.shouldRun( Description.createSuiteDescription( BTest.class ) ) );
+        assertFalse( cut.shouldRun( createSuiteDescription( ABCTest.class ) ) );
+        assertTrue( cut.shouldRun( createSuiteDescription( BBCTest.class ) ) );
+        assertTrue( cut.shouldRun( createSuiteDescription( BTest.class ) ) );
     }
 
     @Test
@@ -105,8 +118,18 @@ public class GroupMatcherCategoryFilterTest
         GroupMatcher excluded =
             new SingleGroupMatcher( "org.apache.maven.surefire.common.junit48.tests.group.marker.CategoryA" );
         cut = new GroupMatcherCategoryFilter( included, excluded );
-        Assert.assertFalse( cut.shouldRun( Description.createSuiteDescription( ATest.class ) ) );
-        Assert.assertTrue( cut.shouldRun( Description.createSuiteDescription( BTest.class ) ) );
-        Assert.assertTrue( cut.shouldRun( Description.createSuiteDescription( BBCTest.class ) ) );
+        assertFalse( cut.shouldRun( createSuiteDescription( ATest.class ) ) );
+        assertTrue( cut.shouldRun( createSuiteDescription( BTest.class ) ) );
+        assertTrue( cut.shouldRun( createSuiteDescription( BBCTest.class ) ) );
+    }
+
+    public static class JUnit4SuiteTest extends TestCase
+    {
+        public static junit.framework.Test suite()
+        {
+            TestSuite suite = new TestSuite();
+            suite.addTest( new JUnit4TestAdapter( GroupMatcherCategoryFilterTest.class ) );
+            return suite;
+        }
     }
 }