maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tibordig...@apache.org
Subject [6/7] maven-surefire git commit: Introduce JUnitVersion enum for configuring tests for different junit versions
Date Fri, 02 Dec 2016 04:03:08 GMT
Introduce JUnitVersion enum for configuring tests for different junit versions


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

Branch: refs/heads/junit5
Commit: 31b55924060c9b8994a28761c8d8722a6f1d491c
Parents: a50c823
Author: Benedikt Ritter <britter@apache.org>
Authored: Mon Oct 10 19:27:26 2016 +0200
Committer: Benedikt Ritter <britter@apache.org>
Committed: Sat Nov 19 14:02:19 2016 +0100

----------------------------------------------------------------------
 .../maven/surefire/its/JUnit4VersionsIT.java    | 92 +++++++++-----------
 .../apache/maven/surefire/its/JUnitVersion.java | 78 +++++++++++++++++
 2 files changed, 118 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/31b55924/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit4VersionsIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit4VersionsIT.java
b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit4VersionsIT.java
index eb7e41e..2df3b1c 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit4VersionsIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit4VersionsIT.java
@@ -29,10 +29,26 @@ import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameter;
 
+import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_10;
+import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_11;
+import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_12;
+import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_8;
+import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_8_1;
+import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_8_2;
+import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_9;
 import static org.junit.runners.Parameterized.*;
 
-import static org.apache.commons.lang3.JavaVersion.JAVA_1_8;
-import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion;
+import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_0;
+import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_1;
+import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_2;
+import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_3;
+import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_3_1;
+import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_4;
+import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_5;
+import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_6;
+import static org.apache.maven.surefire.its.JUnitVersion.JUNIT_4_7;
+import static org.apache.maven.surefire.its.JUnitVersion.JUPITER_5_0_0_M2;
+import static org.apache.maven.surefire.its.JUnitVersion.VINTAGE_4_12_0_M2;
 
 /**
  * Basic suite test using all known versions of JUnit 4.x
@@ -48,31 +64,33 @@ public class JUnit4VersionsIT
     public static Collection<Object[]> junitVersions()
     {
         return Arrays.asList( new Object[][] {
-                { "4.0" },
-                { "4.1" },
-                { "4.2" },
-                { "4.3" },
-                { "4.3.1" },
-                { "4.4" },
-                { "4.5" },
-                { "4.6" },
-                { "4.7" },
-                { "4.8" },
-                { "4.8.1" },
-                { "4.8.2" },
-                { "4.9" },
-                { "4.10" },
-                { "4.11" },
-                { "4.12" }
+                { JUNIT_4_0 },
+                { JUNIT_4_1 },
+                { JUNIT_4_2 },
+                { JUNIT_4_3 },
+                { JUNIT_4_3_1 },
+                { JUNIT_4_4 },
+                { JUNIT_4_5 },
+                { JUNIT_4_6 },
+                { JUNIT_4_7 },
+                { JUNIT_4_8 },
+                { JUNIT_4_8_1 },
+                { JUNIT_4_8_2 },
+                { JUNIT_4_9 },
+                { JUNIT_4_10 },
+                { JUNIT_4_11 },
+                { JUNIT_4_12 },
+                { VINTAGE_4_12_0_M2 },
+                { JUPITER_5_0_0_M2 }
         } );
     }
 
     @Parameter
-    public String version;
+    public JUnitVersion version;
 
     private SurefireLauncher unpack()
     {
-        return unpack( "/junit4", version );
+        return unpack( "/junit4", version.toString() );
     }
 
     @Test
@@ -82,40 +100,10 @@ public class JUnit4VersionsIT
         runJUnitTest( version );
     }
 
-    @Test
-    public void test412M2()
-            throws Exception
-    {
-        assumeJavaVersion( JAVA_1_8 );
-
-        runJUnitTest( "4.12.0-M2" );
-    }
-
-    @Test
-    public void test500M2()
+    private void runJUnitTest( JUnitVersion version )
         throws Exception
     {
-        assumeJavaVersion( JAVA_1_8 );
-
-        runJUnitTest( "5.0.0-M2" );
+        version.configure( unpack() ).executeTest().verifyErrorFree( 1 );
     }
 
-    public void runJUnitTest( String version )
-        throws Exception
-    {
-        unpack().setJUnitVersion( version ).activateProfile( getProfile( version ) ).executeTest().verifyErrorFree(
1 );
-    }
-
-    private String getProfile( String version )
-    {
-        if ( version.startsWith( "4.12" ) )
-        {
-            return "junit5-vintage";
-        }
-        else if ( version.startsWith( "5" ) )
-        {
-            return "junit5-jupiter";
-        }
-        return "junit4";
-    }
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/31b55924/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnitVersion.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnitVersion.java
b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnitVersion.java
new file mode 100644
index 0000000..0bdef4a
--- /dev/null
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnitVersion.java
@@ -0,0 +1,78 @@
+package org.apache.maven.surefire.its;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.surefire.its.fixture.SurefireLauncher;
+
+/**
+ * Enum listing all the JUnit version.
+ */
+public enum JUnitVersion {
+
+    JUNIT_4_0( "4.0" ),
+    JUNIT_4_1( "4.1" ),
+    JUNIT_4_2( "4.2" ),
+    JUNIT_4_3( "4.3" ),
+    JUNIT_4_3_1( "4.3.1" ),
+    JUNIT_4_4( "4.4" ),
+    JUNIT_4_5( "4.5" ),
+    JUNIT_4_6( "4.6" ),
+    JUNIT_4_7( "4.7" ),
+    JUNIT_4_8( "4.8" ),
+    JUNIT_4_8_1( "4.8.1" ),
+    JUNIT_4_8_2( "4.8.2" ),
+    JUNIT_4_9( "4.9" ),
+    JUNIT_4_10( "4.10" ),
+    JUNIT_4_11( "4.11" ),
+    JUNIT_4_12( "4.12" ),
+    VINTAGE_4_12_0_M2( "4.12.0-M2" )
+    {
+        @Override
+        public SurefireLauncher configure( SurefireLauncher launcher )
+        {
+            return super.configure( launcher ).activateProfile( "junit5-vintage" );
+        }
+    },
+    JUPITER_5_0_0_M2( "5.0.0-M2" )
+    {
+        @Override
+        public SurefireLauncher configure( SurefireLauncher launcher )
+        {
+            return super.configure( launcher ).activateProfile( "junit5-jupiter" );
+        }
+    };
+
+    private final String version;
+
+    JUnitVersion( String version )
+    {
+        this.version = version;
+    }
+
+    public SurefireLauncher configure( SurefireLauncher launcher )
+    {
+        return launcher.setJUnitVersion( version );
+    }
+
+    public String toString()
+    {
+        return version;
+    }
+}


Mime
View raw message