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 2015/09/06 22:58:47 UTC

[16/17] maven-surefire git commit: [SUREFIRE-580] integration tests

[SUREFIRE-580] integration tests


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

Branch: refs/heads/master
Commit: 62c7cd0d6885c073efc48d8fdc3c6c77cf05ae03
Parents: 779e381
Author: Tibor17 <ti...@lycos.com>
Authored: Sun Sep 6 10:50:12 2015 +0200
Committer: Tibor17 <ti...@lycos.com>
Committed: Sun Sep 6 22:58:04 2015 +0200

----------------------------------------------------------------------
 .../maven/surefire/its/AbstractFailFastIT.java  | 104 +++++++++++++++++
 .../maven/surefire/its/FailFastJUnitIT.java     |  68 +++++++++++
 .../maven/surefire/its/FailFastTestNgIT.java    |  62 ++++++++++
 .../surefire/its/fixture/MavenLauncher.java     |   9 ++
 .../src/test/resources/fail-fast-junit/pom.xml  | 112 +++++++++++++++++++
 .../src/test/resources/fail-fast-testng/pom.xml |  67 +++++++++++
 6 files changed, 422 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/62c7cd0d/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/AbstractFailFastIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/AbstractFailFastIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/AbstractFailFastIT.java
new file mode 100644
index 0000000..5b79a4d
--- /dev/null
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/AbstractFailFastIT.java
@@ -0,0 +1,104 @@
+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.MavenLauncher;
+import org.apache.maven.surefire.its.fixture.OutputValidator;
+import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.junit.runners.Parameterized.Parameter;
+
+/**
+ * Base test class for SUREFIRE-580, configuration parameter <em>skipAfterFailureCount</em>.
+ *
+ * @author <a href="mailto:tibordigana@apache.org">Tibor Digana (tibor17)</a>
+ * @since 2.19
+ */
+@RunWith( Parameterized.class )
+public abstract class AbstractFailFastIT
+    extends SurefireJUnit4IntegrationTestCase
+{
+    @Parameter( 0 )
+    public String description;
+
+    @Parameter( 1 )
+    public String profile;
+
+    @Parameter( 2 )
+    public Map<String, String> properties;
+
+    @Parameter( 3 )
+    public int total;
+
+    @Parameter( 4 )
+    public int failures;
+
+    @Parameter( 5 )
+    public int errors;
+
+    @Parameter( 6 )
+    public int skipped;
+
+    protected abstract String withProvider();
+
+    protected final OutputValidator prepare( String description, String profile, Map<String, String> properties )
+    {
+        MavenLauncher launcher = unpack( "/fail-fast-" + withProvider(), "_" + description )
+            .maven();
+
+        if ( profile != null )
+        {
+            launcher.addGoal( "-P " + profile );
+        }
+
+        if ( failures != 0 || errors != 0 )
+        {
+            launcher.withFailure();
+        }
+
+        return launcher.sysProp( properties ).executeTest();
+    }
+
+    protected final OutputValidator prepare( String description, Map<String, String> properties )
+    {
+        return prepare( description, null, properties );
+    }
+
+    protected static Map<String, String> props( int forkCount, int skipAfterFailureCount )
+    {
+        Map<String, String> props = new HashMap<String, String>( 2 );
+        props.put( "surefire.skipAfterFailureCount", "" + skipAfterFailureCount );
+        props.put( "forkCount", "" + forkCount );
+        return props;
+    }
+
+    @Test
+    public void test()
+    {
+        prepare( description, profile, properties )
+            .assertTestSuiteResults( total, errors, failures, skipped );
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/62c7cd0d/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/FailFastJUnitIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/FailFastJUnitIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/FailFastJUnitIT.java
new file mode 100644
index 0000000..3a85d5b
--- /dev/null
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/FailFastJUnitIT.java
@@ -0,0 +1,68 @@
+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 java.util.ArrayList;
+
+import static org.junit.runners.Parameterized.Parameters;
+
+/**
+ * Test class for SUREFIRE-580, configuration parameter <em>skipAfterFailureCount</em>.
+ *
+ * @author <a href="mailto:tibordigana@apache.org">Tibor Digana (tibor17)</a>
+ * @since 2.19
+ */
+public class FailFastJUnitIT
+    extends AbstractFailFastIT
+{
+
+    @Parameters(name = "{0}")
+    public static Iterable<Object[]> data()
+    {
+        ArrayList<Object[]> args = new ArrayList<Object[]>();
+        //                        description
+        //                                             profile
+        //                                                       forkCount,
+        //                                                       fail-fast-count
+        //                                                                        total
+        //                                                                             failures
+        //                                                                                     errors
+        //                                                                                           skipped
+        args.add( new Object[] { "junit4-oneFork-ff1", "junit4",   props( 1, 1 ), 5,   0,      1,    4 } );
+        args.add( new Object[] { "junit47-oneFork-ff1", "junit47", props( 1, 1 ), 5,   0,      1,    4 } );
+        args.add( new Object[] { "junit4-oneFork-ff2", "junit4",   props( 1, 2 ), 5,   0,      2,    3 } );
+        args.add( new Object[] { "junit47-oneFork-ff2", "junit47", props( 1, 2 ), 5,   0,      2,    3 } );
+        args.add( new Object[] { "junit4-twoForks-ff1", "junit4",  props( 2, 1 ), 5,   0,      1,    4 } );
+        args.add( new Object[] { "junit47-twoForks-ff1", "junit47",props( 2, 1 ), 5,   0,      1,    4 } );
+        args.add( new Object[] { "junit4-twoForks-ff2", "junit4",  props( 2, 2 ), 5,   0,      2,    3 } );
+        args.add( new Object[] { "junit47-twoForks-ff2", "junit47",props( 2, 2 ), 5,   0,      2,    3 } );
+        args.add( new Object[] { "junit4-oneFork-ff3", "junit4",   props( 1, 3 ), 5,   0,      2,    0 } );
+        args.add( new Object[] { "junit47-oneFork-ff3", "junit47", props( 1, 3 ), 5,   0,      2,    0 } );
+        args.add( new Object[] { "junit4-twoForks-ff3", "junit4",  props( 2, 3 ), 5,   0,      2,    0 } );
+        args.add( new Object[] { "junit47-twoForks-ff3", "junit47",props( 2, 3 ), 5,   0,      2,    0 } );
+        return args;
+    }
+
+    @Override
+    protected String withProvider()
+    {
+        return "junit";
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/62c7cd0d/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/FailFastTestNgIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/FailFastTestNgIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/FailFastTestNgIT.java
new file mode 100644
index 0000000..1c2a3bd
--- /dev/null
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/FailFastTestNgIT.java
@@ -0,0 +1,62 @@
+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 java.util.ArrayList;
+
+import static org.junit.runners.Parameterized.Parameters;
+
+/**
+ * Test class for SUREFIRE-580, configuration parameter <em>skipAfterFailureCount</em>.
+ *
+ * @author <a href="mailto:tibordigana@apache.org">Tibor Digana (tibor17)</a>
+ * @since 2.19
+ */
+public class FailFastTestNgIT
+    extends AbstractFailFastIT
+{
+
+    @Parameters(name = "{0}")
+    public static Iterable<Object[]> data()
+    {
+        ArrayList<Object[]> args = new ArrayList<Object[]>();
+        //                        description
+        //                                             profile
+        //                                                       forkCount,
+        //                                                       fail-fast-count
+        //                                                                        total
+        //                                                                             failures
+        //                                                                                     errors
+        //                                                                                           skipped
+        args.add( new Object[] { "testng-oneFork-ff1", null,     props( 1, 1 ),   5,   1,      0,    4 } );
+        args.add( new Object[] { "testng-oneFork-ff2", null,     props( 1, 2 ),   5,   2,      0,    3 } );
+        args.add( new Object[] { "testng-twoForks-ff1", null,    props( 2, 1 ),   5,   1,      0,    4 } );
+        args.add( new Object[] { "testng-twoForks-ff2", null,    props( 2, 2 ),   5,   2,      0,    3 } );
+        args.add( new Object[] { "testng-oneFork-ff3", null,     props( 2, 3 ),   5,   2,      0,    0 } );
+        args.add( new Object[] { "testng-twoForks-ff3", null,    props( 2, 3 ),   5,   2,      0,    0 } );
+        return args;
+    }
+
+    @Override
+    protected String withProvider()
+    {
+        return "testng";
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/62c7cd0d/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java
index ef5dc33..1198fcb 100755
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/MavenLauncher.java
@@ -337,6 +337,15 @@ public class MavenLauncher
         return addGoal( "-D" + variable + "=" + value );
     }
 
+    public MavenLauncher sysProp( Map<String, String> properties )
+    {
+        for ( Map.Entry<String, String> property : properties.entrySet() )
+        {
+            sysProp( property.getKey(), property.getValue() );
+        }
+        return this;
+    }
+
     public MavenLauncher sysProp( String variable, boolean value )
     {
         return addGoal( "-D" + variable + "=" + value );

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/62c7cd0d/surefire-integration-tests/src/test/resources/fail-fast-junit/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/fail-fast-junit/pom.xml b/surefire-integration-tests/src/test/resources/fail-fast-junit/pom.xml
new file mode 100644
index 0000000..6a6be11
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/fail-fast-junit/pom.xml
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<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/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>
+  </parent>
+
+  <groupId>org.apache.maven.plugins.surefire</groupId>
+  <artifactId>jiras-surefire-580-junit</artifactId>
+  <version>1.0</version>
+
+  <properties>
+    <junit>4.0</junit>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>${junit}</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <runOrder>alphabetical</runOrder>
+          <reuseForks>true</reuseForks>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <profiles>
+    <profile>
+      <id>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>
+    <profile>
+      <id>junit47</id>
+      <properties>
+        <junit>4.7</junit>
+      </properties>
+      <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>
+  </profiles>
+
+</project>

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/62c7cd0d/surefire-integration-tests/src/test/resources/fail-fast-testng/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/fail-fast-testng/pom.xml b/surefire-integration-tests/src/test/resources/fail-fast-testng/pom.xml
new file mode 100644
index 0000000..4fb8385
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/fail-fast-testng/pom.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<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/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>
+  </parent>
+
+  <groupId>org.apache.maven.plugins.surefire</groupId>
+  <artifactId>jiras-surefire-580-testng</artifactId>
+  <version>1.0</version>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.testng</groupId>
+      <artifactId>testng</artifactId>
+      <version>5.10</version>
+      <classifier>jdk15</classifier>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <runOrder>alphabetical</runOrder>
+          <reuseForks>true</reuseForks>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>