0

I am using maven 2 and integration test are in *IT.java files. When I run command mvn failsafe:integration-test integration test run fines. But when I run mvn integration-test it does not run my integration tests. How can I remove prefix failsafe: ?

In pom.xml I use:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>2.12</version>
    <executions>
        <execution>
        <phase>integration-test</phase>
        <goals>
            <goal>integration-test</goal>
            <goal>verify</goal>
        </goals>
        </execution>
    </executions>
</plugin>

UPDATE
I also tried following pom.xml setup and then mvn clean verify. I got only surefire report of JUnit tests. There are still missing JUnit integration test on console output.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>2.12</version>
    <executions>
        <execution>
            <id>failsafe-integration-tests</id>
            <phase>integration-test</phase>
            <goals>
                <goal>integration-test</goal>
            </goals>
        </execution>
        <execution>
            <id>failsafe-verify</id>
            <phase>verify</phase>
            <goals>
                <goal>verify</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Now I tied disable unit tests by plugin settings:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <!-- Disable unit tests -->
        <skip>true</skip>
    </configuration>
</plugin>

Wen I run mvn clean verify my failsafe integration test runs! But why it does not works together with surefire unit test? Any idea?

A_Di-Matteo
  • 26,902
  • 7
  • 94
  • 128
martin
  • 101
  • 2
  • 8
  • Where did you defined that? in Build area or in pluginManagement area? – khmarbaise Aug 09 '12 at 14:41
  • Did you explicitly specify the phase? I helped someone else with a [similar issue](http://stackoverflow.com/a/9949341/944849) and adding the phase helped. The goal is supposed to be bound to the `integration-test` phase by default per the docs but it didn't work until the phase was added explicitly. – user944849 Aug 09 '12 at 15:54
  • 1
    To run your integration tests you have to call the lifecycle phase: verify. If you call the lifecylce integration-test the phase post-integration-test is missing (http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference). Ah are you using JUnit or TestNG? – khmarbaise Aug 10 '12 at 07:07

1 Answers1

2

Do you have failing unit tests?

When you do mvn failsafe:integration-test you are explictly invoking failsafe, but when you do mvn integration-test you are invoking the phase, so unit tests are executed and, in case a unit tests fails, the integration phase is never reached. That would explain why mvn clean verify works when you skip by configuration the execution of the unit tests.

diegomtassis
  • 3,557
  • 2
  • 19
  • 29