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 2018/02/21 20:04:24 UTC

maven-surefire git commit: [SUREFIRE-1481] Surefire1295AttributeJvmCrashesToTestsIT should be Parameterized test instead of using Theories runner

Repository: maven-surefire
Updated Branches:
  refs/heads/SUREFIRE-1481 [created] 67532245c


[SUREFIRE-1481] Surefire1295AttributeJvmCrashesToTestsIT should be Parameterized test instead of using Theories runner


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

Branch: refs/heads/SUREFIRE-1481
Commit: 67532245ca458acd7051afbd2e3db86f605fef17
Parents: d46556f
Author: Tibor17 <ti...@apache.org>
Authored: Wed Feb 21 21:04:10 2018 +0100
Committer: Tibor17 <ti...@apache.org>
Committed: Wed Feb 21 21:04:10 2018 +0100

----------------------------------------------------------------------
 ...urefire1295AttributeJvmCrashesToTestsIT.java | 50 +++++++++++++-------
 1 file changed, 33 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/67532245/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java
----------------------------------------------------------------------
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java
index e160f7a..96e6f41 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1295AttributeJvmCrashesToTestsIT.java
@@ -22,22 +22,27 @@ package org.apache.maven.surefire.its.jiras;
 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.experimental.theories.DataPoints;
-import org.junit.experimental.theories.FromDataPoints;
-import org.junit.experimental.theories.Theories;
-import org.junit.experimental.theories.Theory;
+import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
 
 import java.util.Iterator;
 
+import static java.util.Arrays.asList;
 import static java.util.concurrent.TimeUnit.SECONDS;
 import static org.apache.commons.lang3.SystemUtils.IS_OS_LINUX;
 import static org.apache.commons.lang3.SystemUtils.IS_OS_MAC_OSX;
 import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS_7;
 import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS_8;
 import static org.apache.commons.lang3.SystemUtils.IS_OS_WINDOWS_10;
+import static org.apache.maven.surefire.its.jiras.Surefire1295AttributeJvmCrashesToTestsIT.ForkMode.DEFAULT;
+import static org.apache.maven.surefire.its.jiras.Surefire1295AttributeJvmCrashesToTestsIT.ForkMode.ONE_FORK_NO_REUSE;
+import static org.apache.maven.surefire.its.jiras.Surefire1295AttributeJvmCrashesToTestsIT.ForkMode.ONE_FORK_REUSE;
 import static org.fest.assertions.Assertions.assertThat;
 import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeTrue;
 
 /**
  * https://issues.apache.org/jira/browse/SUREFIRE-1295
@@ -46,7 +51,7 @@ import static org.junit.Assert.fail;
  * @author michaeltandy
  * @since 2.20
  */
-@RunWith( Theories.class )
+@RunWith( Parameterized.class )
 public class Surefire1295AttributeJvmCrashesToTestsIT
         extends SurefireJUnit4IntegrationTestCase
 {
@@ -57,22 +62,33 @@ public class Surefire1295AttributeJvmCrashesToTestsIT
         ONE_FORK_REUSE
     }
 
-    @DataPoints( "crashStyle" )
-    public static String[] crashStyle = { "exit", "abort", "segfault" };
+    @Parameters
+    public static Iterable<Object[]> parameters()
+    {
+        return asList(new Object[][] {
+                { "exit", DEFAULT },
+                { "exit", ONE_FORK_NO_REUSE },
+                { "exit", ONE_FORK_REUSE },
+                { "abort", DEFAULT },
+                { "abort", ONE_FORK_NO_REUSE },
+                { "abort", ONE_FORK_REUSE },
+                { "segfault", DEFAULT },
+                { "segfault", ONE_FORK_NO_REUSE },
+                { "segfault", ONE_FORK_REUSE }
+        });
+    }
+
+    @Parameter( 0 )
+    public static String crashStyle;
 
-    @DataPoints( "forkStyle" )
-    public static ForkMode[] forkStyle = ForkMode.values();
+    @Parameter( 1 )
+    public static ForkMode forkStyle;
 
-    @Theory
-    public void test( @FromDataPoints( "crashStyle" ) String crashStyle,
-                      @FromDataPoints( "forkStyle" ) ForkMode forkStyle )
+    @Test
+    public void test()
             throws Exception
     {
-        // JUnit Assumptions not supported by Theories runner.
-        if ( !IS_OS_LINUX && !IS_OS_MAC_OSX && !( IS_OS_WINDOWS_7 || IS_OS_WINDOWS_8 || IS_OS_WINDOWS_10 ) )
-        {
-            return;
-        }
+        assumeTrue( IS_OS_LINUX || IS_OS_MAC_OSX || IS_OS_WINDOWS_7 || IS_OS_WINDOWS_8 || IS_OS_WINDOWS_10 );
 
         SurefireLauncher launcher =
                 unpack( "crash-during-test", "_" + crashStyle + "_" + forkStyle.ordinal() )