I have some integration tests that depend on test data. This test data is created in phase pre-integration-test
and removed in phase post-integration-test
.
My problem is that these phases are still executed if I use -DskipITs
on the Maven commandline.
Is there any way to make -DskipITs
also skip the pre-integration-test and post-integration-test phases?
This is the plugin definition in the pom:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.5</version>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
</dependencies>
<configuration>
<driver>com.mysql.jdbc.Driver</driver>
<url>${database.url}</url>
<username>${database.user}</username>
<password>${database.pw}</password>
</configuration>
<executions>
<execution>
<id>create-integration-test-data</id>
<phase>pre-integration-test</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<orderFile>descending</orderFile>
<fileset>
<basedir>${basedir}/src/test/resources/sql</basedir>
<includes>
<include>AdministrationTestTeardown.sql</include>
<include>AdministrationTestSetup.sql</include>
</includes>
</fileset>
</configuration>
</execution>
<execution>
<id>remove-data-after-test</id>
<phase>post-integration-test</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<fileset>
<basedir>${basedir}/src/test/resources/sql</basedir>
<includes>
<include>AdministrationTestTeardown.sql</include>
</includes>
</fileset>
</configuration>
</execution>
</executions>
</plugin>
Better way is to use the skipITs property to skip the execution of both pre-integration & post-integration phases.
In your case, it will look like :
<executions>
<execution>
<id>create-integration-test-data</id>
<phase>pre-integration-test</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<skip>${skipITs}</skip>
<orderFile>descending</orderFile>
<fileset>
<basedir>${basedir}/src/test/resources/sql</basedir>
<includes>
<include>AdministrationTestTeardown.sql</include>
<include>AdministrationTestSetup.sql</include>
</includes>
</fileset>
</configuration>
</execution>
<execution>
<id>remove-data-after-test</id>
<phase>post-integration-test</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<skip>${skipITs}</skip>
<fileset>
<basedir>${basedir}/src/test/resources/sql</basedir>
<includes>
<include>AdministrationTestTeardown.sql</include>
</includes>
</fileset>
</configuration>
</execution>
</executions>
So, whenever you run mvn command with -DskipITs, it will skip the integration test as well the execution of this plugin.