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 2019/12/01 02:22:43 UTC

[maven-surefire] branch junit5-runorder created (now f7f928e)

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

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


      at f7f928e  Run Order / JUnit5 supported in the Feature Matrix + tests

This branch includes the following new commits:

     new f7f928e  Run Order / JUnit5 supported in the Feature Matrix + 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: Run Order / JUnit5 supported in the Feature Matrix + tests

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

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

commit f7f928eab214d42898aee5eadb0747b93b16f926
Author: tibordigana <ti...@apache.org>
AuthorDate: Sun Dec 1 03:22:35 2019 +0100

    Run Order / JUnit5 supported in the Feature Matrix + tests
---
 .../src/site/apt/featurematrix.apt.vm              |  3 +-
 .../org/apache/maven/surefire/its/RunOrderIT.java  | 81 ++++++++++++++++++----
 surefire-its/src/test/resources/runOrder/pom.xml   | 34 ++++++---
 3 files changed, 92 insertions(+), 26 deletions(-)

diff --git a/maven-surefire-plugin/src/site/apt/featurematrix.apt.vm b/maven-surefire-plugin/src/site/apt/featurematrix.apt.vm
index 05d13bc..0cd4c38 100644
--- a/maven-surefire-plugin/src/site/apt/featurematrix.apt.vm
+++ b/maven-surefire-plugin/src/site/apt/featurematrix.apt.vm
@@ -34,7 +34,7 @@ Feature Matrix
 *---------------------------------------------+------------+----------+------------+-----------+----------+----------------------+
 | security manager support                    |     Y      |    N     |      N     |    N      |  N       |  N                   |
 *---------------------------------------------+------------+----------+------------+-----------+----------+----------------------+
-| runOrder support                            |     Y      |    Y     |      Y     |    ?      |  Y       |  N                   |
+| runOrder support                            |     Y      |    Y     |      Y     |    ?      |  Y       |  Y                   |
 *---------------------------------------------+------------+----------+------------+-----------+----------+----------------------+
 | run >1 individual test method in a class    |     N      |    Y     |      Y     |    Y      |  N       |  ?(*1)               |
 *---------------------------------------------+------------+----------+------------+-----------+----------+----------------------+
@@ -63,4 +63,3 @@ Feature Matrix
    (*2) 3 extensions related to JUnit5 annotation <<<DisplayName>>>.
 
    (*3) Since 3.0.0-M4
-   
\ No newline at end of file
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/RunOrderIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/RunOrderIT.java
index d2031fa..6f7ccee 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/RunOrderIT.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/RunOrderIT.java
@@ -41,27 +41,43 @@ public class RunOrderIT
     // testing random is left as an exercise to the reader. Patches welcome
 
     @Test
-    public void testAlphabetical()
+    public void testAlphabeticalJUnit4()
         throws Exception
     {
-        OutputValidator validator = executeWithRunOrder( "alphabetical" );
+        OutputValidator validator = executeWithRunOrder( "alphabetical", "junit4" );
         assertTestnamesAppearInSpecificOrder( validator, TESTS_IN_ALPHABETICAL_ORDER );
     }
 
     @Test
-    public void testReverseAlphabetical()
+    public void testAlphabeticalJUnit5()
         throws Exception
     {
-        OutputValidator validator = executeWithRunOrder( "reversealphabetical" );
+        OutputValidator validator = executeWithRunOrder( "alphabetical", "junit5" );
+        assertTestnamesAppearInSpecificOrder( validator, TESTS_IN_ALPHABETICAL_ORDER );
+    }
+
+    @Test
+    public void testReverseAlphabeticalJUnit4()
+        throws Exception
+    {
+        OutputValidator validator = executeWithRunOrder( "reversealphabetical", "junit4" );
+        assertTestnamesAppearInSpecificOrder( validator, TESTS_IN_REVERSE_ALPHABETICAL_ORDER );
+    }
+
+    @Test
+    public void testReverseAlphabeticalJUnit5()
+        throws Exception
+    {
+        OutputValidator validator = executeWithRunOrder( "reversealphabetical", "junit5" );
         assertTestnamesAppearInSpecificOrder( validator, TESTS_IN_REVERSE_ALPHABETICAL_ORDER );
     }
 
     @Test
-    public void testHourly()
+    public void testHourlyJUnit4()
         throws Exception
     {
         int startHour = Calendar.getInstance().get( Calendar.HOUR_OF_DAY );
-        OutputValidator validator = executeWithRunOrder( "hourly" );
+        OutputValidator validator = executeWithRunOrder( "hourly", "junit4" );
         int endHour = Calendar.getInstance().get( Calendar.HOUR_OF_DAY );
         if ( startHour != endHour )
         {
@@ -74,21 +90,56 @@ public class RunOrderIT
     }
 
     @Test
-    public void testNonExistingRunOrder()
+    public void testHourlyJUnit5()
         throws Exception
     {
+        int startHour = Calendar.getInstance().get( Calendar.HOUR_OF_DAY );
+        OutputValidator validator = executeWithRunOrder( "hourly", "junit5" );
+        int endHour = Calendar.getInstance().get( Calendar.HOUR_OF_DAY );
+        if ( startHour != endHour )
+        {
+            return; // Race condition, cannot test when hour changed mid-run
+        }
+
+        String[] testnames =
+            ( ( startHour % 2 ) == 0 ) ? TESTS_IN_ALPHABETICAL_ORDER : TESTS_IN_REVERSE_ALPHABETICAL_ORDER;
+        assertTestnamesAppearInSpecificOrder( validator, testnames );
+    }
+
+    @Test
+    public void testNonExistingRunOrderJUnit4()
+    {
+        unpack()
+            .activateProfile( "junit4" )
+            .forkMode( getForkMode() )
+            .runOrder( "nonExistingRunOrder" )
+            .maven()
+            .withFailure()
+            .executeTest()
+            .verifyTextInLog( "There's no RunOrder with the name nonExistingRunOrder." );
+    }
+
+    @Test
+    public void testNonExistingRunOrderJUnit5()
+    {
         unpack()
-                .forkMode( getForkMode() )
-                .runOrder( "nonExistingRunOrder" )
-                .maven()
-                .withFailure()
-                .executeTest()
-                .verifyTextInLog( "There's no RunOrder with the name nonExistingRunOrder." );
+            .activateProfile( "junit5" )
+            .forkMode( getForkMode() )
+            .runOrder( "nonExistingRunOrder" )
+            .maven()
+            .withFailure()
+            .executeTest()
+            .verifyTextInLog( "There's no RunOrder with the name nonExistingRunOrder." );
     }
 
-    private OutputValidator executeWithRunOrder( String runOrder )
+    private OutputValidator executeWithRunOrder( String runOrder, String profile )
     {
-        return unpack().forkMode( getForkMode() ).runOrder( runOrder ).executeTest().verifyErrorFree( 3 );
+        return unpack()
+            .activateProfile( profile )
+            .forkMode( getForkMode() )
+            .runOrder( runOrder )
+            .executeTest()
+            .verifyErrorFree( 3 );
     }
 
     protected String getForkMode()
diff --git a/surefire-its/src/test/resources/runOrder/pom.xml b/surefire-its/src/test/resources/runOrder/pom.xml
index 84abb53..8f00c3b 100644
--- a/surefire-its/src/test/resources/runOrder/pom.xml
+++ b/surefire-its/src/test/resources/runOrder/pom.xml
@@ -33,15 +33,6 @@
     <maven.compiler.target>1.7</maven.compiler.target>
   </properties>
 
-  <dependencies>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>4.8.1</version>
-      <scope>test</scope>
-    </dependency>
-  </dependencies>
-
   <build>
     <plugins>
       <plugin>
@@ -57,4 +48,29 @@
     </plugins>
   </build>
 
+    <profiles>
+        <profile>
+            <id>junit4</id>
+            <dependencies>
+                <dependency>
+                    <groupId>junit</groupId>
+                    <artifactId>junit</artifactId>
+                    <version>4.8.1</version>
+                    <scope>test</scope>
+                </dependency>
+            </dependencies>
+        </profile>
+        <profile>
+            <id>junit5</id>
+            <dependencies>
+                <dependency>
+                    <groupId>org.junit.vintage</groupId>
+                    <artifactId>junit-vintage-engine</artifactId>
+                    <version>5.5.2</version>
+                    <scope>test</scope>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>
+
 </project>