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

maven-surefire git commit: [SUREFIRE-1024] "verify" goal ignores "dependenciesToScan" parameter when checking tests existence

Repository: maven-surefire
Updated Branches:
  refs/heads/master 1f19156e0 -> 6bdcc54b1


[SUREFIRE-1024] "verify" goal ignores "dependenciesToScan" parameter when checking tests existence


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

Branch: refs/heads/master
Commit: 6bdcc54b19d1c8e284a4d2401ed018c9684e3564
Parents: 1f19156
Author: Tibor17 <ti...@lycos.com>
Authored: Sat Apr 4 21:56:46 2015 +0200
Committer: Tibor17 <ti...@lycos.com>
Committed: Wed Apr 22 01:02:12 2015 +0200

----------------------------------------------------------------------
 .../maven/plugin/failsafe/VerifyMojo.java       | 37 ++++++---
 .../Surefire1024VerifyFailsafeIfTestedIT.java   | 48 ++++++++++++
 .../jiras-surefire-1024-it/pom.xml              | 79 ++++++++++++++++++++
 .../jiras-surefire-1024-testjar/pom.xml         | 54 +++++++++++++
 .../src/main/java/jiras/surefire1024/A1IT.java  | 12 +++
 .../src/test/resources/surefire-1024/pom.xml    | 51 +++++++++++++
 6 files changed, 269 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/6bdcc54b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
----------------------------------------------------------------------
diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
index 4486aaf..4f9cdf2 100644
--- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
+++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
@@ -157,7 +157,7 @@ public class VerifyMojo
             RunResult summary;
             try
             {
-                String encoding;
+                final String encoding;
                 if ( StringUtils.isEmpty( this.encoding ) )
                 {
                     getLog().warn(
@@ -171,19 +171,13 @@ public class VerifyMojo
                     encoding = this.encoding;
                 }
 
-                if ( !summaryFile.isFile() && summaryFiles != null )
-                {
-                    summary = RunResult.noTestsRun();
-                }
-                else
-                {
-                    summary = readSummary( encoding, summaryFile );
-                }
-                if ( summaryFiles != null )
+                summary = existsSummaryFile() ? readSummary( encoding, summaryFile ) : RunResult.noTestsRun();
+
+                if ( existsSummaryFiles() )
                 {
-                    for ( File file : summaryFiles )
+                    for ( final File summaryFile : summaryFiles )
                     {
-                        summary = summary.aggregate( readSummary( encoding, file ) );
+                        summary = summary.aggregate( readSummary( encoding, summaryFile ) );
                     }
                 }
             }
@@ -232,6 +226,10 @@ public class VerifyMojo
             {
                 throw new MojoFailureException( "No tests to run!" );
             }
+        }
+
+        if ( !existsSummary() )
+        {
             getLog().info( "No tests to run." );
             return false;
         }
@@ -341,4 +339,19 @@ public class VerifyMojo
         this.failIfNoTests = failIfNoTests;
     }
 
+    private boolean existsSummaryFile()
+    {
+        return summaryFile != null && summaryFile.isFile();
+    }
+
+    private boolean existsSummaryFiles()
+    {
+        return summaryFiles != null && summaryFiles.length != 0;
+    }
+
+    private boolean existsSummary()
+    {
+        return existsSummaryFile() || existsSummaryFiles();
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/6bdcc54b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1024VerifyFailsafeIfTestedIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1024VerifyFailsafeIfTestedIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1024VerifyFailsafeIfTestedIT.java
new file mode 100644
index 0000000..9866dd5
--- /dev/null
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1024VerifyFailsafeIfTestedIT.java
@@ -0,0 +1,48 @@
+package org.apache.maven.surefire.its.jiras;
+
+/*
+ * 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.SurefireJUnit4IntegrationTestCase;
+import org.apache.maven.surefire.its.fixture.SurefireLauncher;
+import org.junit.Test;
+
+/**
+ * "verify" goal ignores "dependenciesToScan" parameter when checking tests existence
+ * <p>
+ * Found in Surefire 2.16.
+ *
+ * @author <a href="mailto:tibordigana@apache.org">Tibor Digana (tibor17)</a>
+ * @see {@linkplain https://jira.codehaus.org/browse/SUREFIRE-1024}
+ * @since 2.19
+ */
+public class Surefire1024VerifyFailsafeIfTestedIT
+    extends SurefireJUnit4IntegrationTestCase
+{
+
+    @Test
+    public void shouldScanAndRunTestsInDependencyJars() throws Exception {
+        SurefireLauncher launcher = unpack( "surefire-1024" );
+        launcher.executeVerify()
+            .verifyTextInLog( "class jiras.surefire1024.A1IT#test() dependency to scan" );
+
+        launcher.getSubProjectValidator( "jiras-surefire-1024-it" )
+            .assertIntegrationTestSuiteResults( 1, 0, 0, 0 );
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/6bdcc54b/surefire-integration-tests/src/test/resources/surefire-1024/jiras-surefire-1024-it/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-1024/jiras-surefire-1024-it/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1024/jiras-surefire-1024-it/pom.xml
new file mode 100644
index 0000000..1629429
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/surefire-1024/jiras-surefire-1024-it/pom.xml
@@ -0,0 +1,79 @@
+<?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.plugins.surefire</groupId>
+    <artifactId>jiras-surefire-1024</artifactId>
+    <version>1.0</version>
+  </parent>
+
+  <artifactId>jiras-surefire-1024-it</artifactId>
+  <version>1.0</version>
+  <packaging>pom</packaging>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.8.1</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.plugins.surefire</groupId>
+      <artifactId>jiras-surefire-1024-testjar</artifactId>
+      <version>1.0</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-failsafe-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>integration-test</id>
+            <phase>integration-test</phase>
+            <goals>
+              <goal>integration-test</goal>
+            </goals>
+          </execution>
+          <execution>
+            <id>verify</id>
+            <phase>verify</phase>
+            <goals>
+              <goal>verify</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <dependenciesToScan>
+            <dependency>org.apache.maven.plugins.surefire:jiras-surefire-1024-testjar</dependency>
+          </dependenciesToScan>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/6bdcc54b/surefire-integration-tests/src/test/resources/surefire-1024/jiras-surefire-1024-testjar/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-1024/jiras-surefire-1024-testjar/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1024/jiras-surefire-1024-testjar/pom.xml
new file mode 100644
index 0000000..f38b200
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/surefire-1024/jiras-surefire-1024-testjar/pom.xml
@@ -0,0 +1,54 @@
+<?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.plugins.surefire</groupId>
+    <artifactId>jiras-surefire-1024</artifactId>
+    <version>1.0</version>
+  </parent>
+
+  <artifactId>jiras-surefire-1024-testjar</artifactId>
+  <version>1.0</version>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.8.1</version>
+      <optional>true</optional>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/6bdcc54b/surefire-integration-tests/src/test/resources/surefire-1024/jiras-surefire-1024-testjar/src/main/java/jiras/surefire1024/A1IT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-1024/jiras-surefire-1024-testjar/src/main/java/jiras/surefire1024/A1IT.java b/surefire-integration-tests/src/test/resources/surefire-1024/jiras-surefire-1024-testjar/src/main/java/jiras/surefire1024/A1IT.java
new file mode 100644
index 0000000..e5d71a2
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/surefire-1024/jiras-surefire-1024-testjar/src/main/java/jiras/surefire1024/A1IT.java
@@ -0,0 +1,12 @@
+package jiras.surefire1024;
+
+import org.junit.Test;
+
+public class A1IT
+{
+    @Test
+    public void test()
+    {
+        System.out.println( getClass() + "#test() dependency to scan" );
+    }
+}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/6bdcc54b/surefire-integration-tests/src/test/resources/surefire-1024/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-1024/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1024/pom.xml
new file mode 100644
index 0000000..bc28104
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/surefire-1024/pom.xml
@@ -0,0 +1,51 @@
+<?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-1024</artifactId>
+  <version>1.0</version>
+  <packaging>pom</packaging>
+  <url>http://maven.apache.org</url>
+  <developers>
+    <developer>
+      <id>tibordigana</id>
+      <name>Tibor Digaňa (tibor17)</name>
+      <email>tibordigana@apache.org</email>
+      <roles>
+        <role>Committer</role>
+      </roles>
+      <timezone>Europe/Bratislava</timezone>
+    </developer>
+  </developers>
+
+  <modules>
+    <module>jiras-surefire-1024-testjar</module>
+    <module>jiras-surefire-1024-it</module>
+  </modules>
+
+</project>