Feel my pain
We use OSGi, but we don’t deploy our bundles further than testing environment. It is our client who deploys it to production. However, they rarely read Read more
We use OSGi, but we don’t deploy our bundles further than testing environment. It is our client who deploys it to production. However, they rarely read Read more
The Maven Failsafe Plugin is a fork of the Maven Surefire Plugin designed to help when running integration tests. However, sometimes you may want to use Surefire for integration Read more
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.15</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
What I did here is forcing maven to skip default test phase. Instead of that, I will configure two separate executions (just below the <configuration> section):
<executions>
<execution>
<id>unit-tests</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<includes>
<include>**/*Test.class</include>
<include>**/*Spec.class</include>
</includes>
<excludes>
<exclude>**/*IntegrationTest.class</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>integration-tests</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
<includes>
<include>**/*IntegrationTest.class</include>
</includes>
</configuration>
</execution>
</executions>
In unit test execution I include all test that match naming convention for unit tests (both JUnit and spock ones) and exclude files matching integration test pattern and in integration test execution I did something opposite ;)
package info.rnowak.webtex.common.test;
public interface IntegrationTest {
}
Then we can mark our integration test class with:
@Category(IntegrationTest.class)
Next thing is changing of surefire plugin configuration to omit integration test:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.15</version>
<configuration>
<includes>
<include>**/*Test.class</include>
<include>**/*Spec.class</include>
</includes>
<excludedGroups>info.rnowak.webtex.common.test.IntegrationTest</excludedGroups>
</configuration>
</plugin>
What has changed here is new <excludedGroups> tag with name of interface which marks our integration tests.
Next, we need to add and configure maven-failsafe plugin in order to run test from out integration test group:
<plugin><plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.15</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<groups>info.rnowak.webtex.common.test.IntegrationTest</groups>
<includes>
<include>**/*.class</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
With this configuration failsafe will run only test marked with @Category(IntegrationTest.class) annotation, no matter what their names are.
<dependency>
<groupid>org.spockframework</groupId>
<artifactid>spock-core</artifactId>
<version>0.7-groovy-2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupid>org.codehaus.groovy</groupId>
<artifactid>groovy-all</artifactId>
<version>${groovy.version}</version>
<scope>test</scope>
</dependency>
Where groovy.version is property defined in pom.xml for more convenient use and easy version change, just like this:
<properties>
<gmaven-plugin.version>1.4</gmaven-plugin.version>
<groovy.version>2.1.5</groovy.version>
</properties>
<dependency>
<groupid>cglib</groupId>
<artifactid>cglib-nodep</artifactId>
<version>3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupid>org.objenesis</groupId>
<artifactid>objenesis</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<plugin>
<groupid>org.codehaus.gmaven</groupId>
<artifactid>gmaven-plugin</artifactId>
<version>${gmaven-plugin.version}</version>
<configuration>
<providerselection>2.0</providerSelection>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupid>org.codehaus.gmaven.runtime</groupId>
<artifactid>gmaven-runtime-2.0</artifactId>
<version>${gmaven-plugin.version}</version>
<exclusions>
<exclusion>
<groupid>org.codehaus.groovy</groupId>
<artifactid>groovy-all</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupid>org.codehaus.groovy</groupId>
<artifactid>groovy-all</artifactId>
<version>${groovy.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupid>org.apache.maven.plugins</groupId>
<artifactid>maven-surefire-plugin</artifactId>
<version>2.15</version>
<configuration>
<includes>
<include>**/*Test.java</include>
<include>**/*Spec.java</include>
</includes>
</configuration>
</plugin>
<include>**/*Test.class</include>
<include>**/*Spec.class</include>
(thanks to Tomek Pęksa for pointing this out!)Problems with syntetic code benchmarks like sonar (with coberture) often link to problematic project configuration. It took me at least few moths to find source of “0% Read more
Using locale specific characters in schema or wsdl (i.e. for documentation purpose) is still quite problematic. Especially if you are using JAXB to generate wsdl2java Read more
Using maven release plugin can save you a lot of time, especially if you still manually mange your project versioning. But sometimes it can be pain in the “back”. Simple Read more