0

I have configured failsafe together with tomcat7-maven-plugin for making integration-test. It's great and works very well when I type:

mvn clean verify -P integration-test

My pom.xml is like that:

        <!-- Runs integration tests -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.18</version>
            <executions>
                <!-- Invokes both the integration-test and the verify goals of the Failsafe Maven plugin -->
                <execution>
                    <id>integration-tests</id>
                    <goals>
                        <goal>integration-test</goal>
                        <goal>verify</goal>
                    </goals>
                    <configuration>
                        <!-- Skips integration tests if the value of skip.integration.tests property is true -->
                        <skipTests>${skip.integration.tests}</skipTests>
                    </configuration>
                </execution>
            </executions>
        </plugin>


        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
              <path>/onde-vou</path>
            </configuration>
            <executions>
              <execution>
                <id>start-tomcat</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>run</goal>
                </goals>
                <configuration>
                  <fork>true</fork>
                </configuration>
              </execution>
              <execution>
                <id>stop-tomcat</id>
                <phase>post-integration-test</phase>
                <goals>
                  <goal>shutdown</goal>
                </goals>
              </execution>
            </executions>
        </plugin>

But I got an unexpected behavior. When I type:

mvn clean install

It starts the tomcat and shutdown at the end of the process. How do I avoid this behavior? It is useless for me and I lose some secs.

1 Answers1

1

You can try mvn clean install -Dmaven.test.skip=true which skip the test, hence skips the execution pre-integration-test

or remove

<executions>
  <execution>
    <id>start-tomcat</id>
    <phase>pre-integration-test</phase>
    <goals>
      <goal>run</goal>
    </goals>
    <configuration>
      <fork>true</fork>
    </configuration>
  </execution>
  <execution>
    <id>stop-tomcat</id>
    <phase>post-integration-test</phase>
    <goals>
      <goal>shutdown</goal>
    </goals>
  </execution>
</executions>
Danielson
  • 2,605
  • 2
  • 28
  • 51
  • Fair enough, but how about the first line? `mvn clean install -Dmaven.test.skip=true`... Starting and shutting down the tomcat is part of the unit test... – Danielson Sep 09 '15 at 13:19
  • It did not work. I need tomcat only for integration-test and it is working. When I type mvn install it runs the unit test first at the end run tomcat I do not know for what: `Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO] --- maven-war-plugin:2.3:war (default-war) @ onde-vou --- [INFO] Building war [INFO] >>> tomcat7-maven-plugin:2.2:run (start-tomcat) ` – Sérgio Campos da Fonseca Sep 09 '15 at 13:27
  • http://stackoverflow.com/a/17123957/928952 , or mvn install -DskipTests see http://maven.apache.org/surefire/maven-surefire-plugin/examples/skipping-test.html – Danielson Sep 09 '15 at 13:32