2

I am trying to move some integration tests into the project that assembles the final EAR. Test I want to run are in src/test/java/it. There is nothing in src/main. However, when the build executes tests dont run and following message is displayed:

[INFO] --- maven-failsafe-plugin:2.19.1:integration-test (integration-test) @ project ---
[INFO] No tests to run.

If I change the packaging tests execute with same exact failsafe configuration. Why and how is EAR plugin different? Is there a way to run tests after building an EAR?

aiguy
  • 671
  • 5
  • 20
  • 2
    They should be located in `src/it/java`: https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html also http://stackoverflow.com/q/17865088/1743880 – Tunaki Mar 08 '16 at 21:33
  • Simply not correct, cause it depends on how you configure maven-failsafe-plugin. By default it will search integration tests (identified by naming conventions) in `src/test/java`...What you have mentioned is explicitly mentioned for integration tests of plugins and furthermore only `src/it/` and not `src/it/java`... – khmarbaise Mar 09 '16 at 15:41

2 Answers2

1

First you should locate your tests into src/test/java and simply naming accordingly the naming conventions of maven-failsafe-plugin which looks like this:

<includes>
 <include>**/IT*.java</include>
 <include>**/*IT.java</include>
 <include>**/*ITCase.java</include>
</includes>

Furthermore if you configured maven-failsafe-plugin accordingly to the documentation like this:

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>2.19.1</version>
        <executions>
          <execution>
            <goals>
              <goal>integration-test</goal>
              <goal>verify</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  [...]
</project>

then maven-failsafe-plugin will be executed during the integration-test phase which is after the package phase (where the ear file will be packaed). So you can simply run maven via:

mvn clean verify 
khmarbaise
  • 92,914
  • 28
  • 189
  • 235
0

The different behaviour is caused by the ear packaging.

As documented here, this packaging only has lifecycle bindings for the phases generate-resources, process-resources, package, install and deploy.

Harald Albers
  • 1,913
  • 16
  • 20