Uploaded image for project: 'Maven Surefire'
  1. Maven Surefire
  2. SUREFIRE-1024

"verify" goal ignores "dependenciesToScan" parameter when checking tests existence

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.16
    • Fix Version/s: 2.19
    • Component/s: Maven Failsafe Plugin
    • Labels:
      None
    • Flags:
      Patch

      Description

      Consider Maven project with packaging=pom that executes tests from some external jar:

      <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/xsd/maven-4.0.0.xsd">
          <modelVersion>4.0.0</modelVersion>
          <groupId>test</groupId>
          <artifactId>test</artifactId>
          <version>test</version>
          <packaging>pom</packaging>
          <dependencies>
              <dependency>
                  <groupId>test</groupId>
                  <artifactId>tests-jar</artifactId>
                  <version>1.0</version>
                  <classifier>tests</classifier>
              </dependency>
              <dependency>
                  <groupId>org.testng</groupId>
                  <artifactId>testng</artifactId>
                  <version>6.8</version>
              </dependency>
          </dependencies>
      
          <build>
                      <plugins>
                          <plugin>
                              <artifactId>maven-failsafe-plugin</artifactId>
                              <version>2.17-SNAPSHOT</version>
                              <configuration>
                                  <dependenciesToScan>
                                      <dependency>test:tests-jar</dependency>
                                  </dependenciesToScan>
                              </configuration>
                              <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>
                          </plugin>
                      </plugins>
          </build>
      </project>
      

      (real use case is execution of prebuilt end-to-end tests of some system after its deployment)

      When we run `mvn clean verify` on such project, failsafe plugin's "verify" goal reports the following:

      [INFO] --- maven-failsafe-plugin:2.16:verify (verify) @ test ---
      [INFO] No tests to run.
      

      Consequently, even if there are test failures, build success is reported.

      The reason of such behavior is that VerifyMojo ignores "dependenciesToScan" parameter. So, the fix is easy - check its existence along with "testClassesDirectory" existence, the same way as implemented in AbstractSurefireMojo.

      The patch in attachment includes integration test that checks for build failure when there is failed test from dependency jar.

        Attachments

          Activity

            People

            • Assignee:
              tibordigana Tibor Digana
              Reporter:
              dmitry.kholodilov Dmitry Kholodilov
            • Votes:
              3 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: