I am attempting to configure my Maven project to have unit tests and integration tests. The unit tests are already working fine using the Maven Surefire plugin and are named according to the pattern *Test.java
.
After adding the Failsafe plugin, like so:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.18.1</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.18.1</version>
</dependency>
</dependencies>
<configuration>
<includes>
<include>**/*IT.java</include>
</includes>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
</plugin>
I added an integration test named SomeTestIT.java
. However, when I run:
mvn failsafe:integration-test
I get the following:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MyApp 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-failsafe-plugin:2.18.1:integration-test (default-cli) @ MyApp ---
[INFO] Tests are skipped.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.368 s
[INFO] Finished at: 2015-03-04T14:43:50-06:00
[INFO] Final Memory: 11M/219M
[INFO] ------------------------------------------------------------------------
My test class (buried a few package levels deep beneath the test hierarchy) looks something like:
package com.example.my.package;
import org.junit.Test;
import org.junit.Assert;
import com.example.my.package.SomeService;
import org.junit.runner.RunWith;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.beans.factory.annotation.Autowired;
@RunWith(SpringJUnit4ClassRunner.class)
public class SomeTestIT
{
@Autowired
private SomeService target;
@Test
public void testTest()
{
Assert.assertTrue(false);
}
@Test
public void basicListTest()
{
Assert.assertNotNull(target);
}
}
Where the tests are stubs to make sure that I have the Maven integration working.
I have ensured that:
Nonetheless, the tests never actually run. Is there anything else necessary to get the integration tests running?
I finally figured out what was going on and wanted to keep anyone else from spinning their wheels like I did. In the <properties>
tag at the head of the POM, someone had added a property that read <skipITs>true</skipITs>
. There were no integration tests previously, so the property was useless. It was probably cargo-culted out of some other POM without any real regard for what it is or what it does.
My problem was that maven failsafe plugin was already defined in some parent pom and was configured oddly.
In general, the best way I have found to handle this kind of issues is to first look at the effective pom:
mvn help:effective-pom
and check (1) all properties (2) the configuration of the problematic plugin
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With