Вопрос

I've specified the use of Failsafe in a parent POM. When I run mvn verify on my multi-module build, there is no hint of Failsafe being run - it appears nowhere in the console output.

If I add the same <plugin> definition into a child POM, it does get run (although it complains about not being able to find \failsafe-reports\failsafe-summary.xml).

Surely it should be inheriting which plugins are to be run?

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>2.15</version>
    <executions>
        <execution>
            <goals>
                <goal>verify</goal>
            </goals>
        </execution>
    </executions>
</plugin>
Это было полезно?

Решение

First you should define it in pluginManagement like this:

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-failsafe-plugin</artifactId>
          <version>2.15</version>
          <executions>
            <execution>
              <id>integration-test</id>
              <goals>
                <goal>integration-test</goal>
                <goal>verify</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

The important part is to use the goals integration-test and verify and not only verify. Aaprt from the above you need to define the real usage like this:

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
      </plugin>
    </plugins>
  </build>
  [...]
</project>

You can activate the usage separately in every sub-module you would like to use integration tests by adding the above snippet. This is usually only in a few modules the case.

Другие советы

You need to add the goal integration-test

              <goals>
                 <goal>integration-test</goal>
                 <goal>verify</goal>
              </goals>

The goal verify, just checks the generated report (failsafe-summary.xml) to see if there was a test error, and fails the build.

The goal integration-test actually runs the tests, at least the classes which match IT*.java, IT.java and ITCase.java by default.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top