Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven does not run integration tests using failsafe-plugin

I know this question is asked more than once. But I cannot make maven run my integration tests using failsafe-plugin.

When I execute mvn failsafe:integration-test failsafe:verify it runs my integration tests. But when I execute mvn verify my integration tests are not running.

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.bahadirakin</groupId>
<artifactId>integration-tests</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>integration-tests</name>
<url>http://maven.apache.org</url>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

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

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
</dependencies>
</project>

An integration test

package com.bahadirakin.integration;

import org.junit.Assert;
import org.junit.Test;

public class ServiceIT {

    @Test
    public void testFail() throws Exception {
        Assert.fail();

    }
}

As you can see I expect it to fail.

Maven version

Apache Maven 3.2.3 (33f8c3e1027c3ddde99d3cdebad2656a31e8fdf4; 2014-08-11T23:58:10+03:00)
Maven home: /usr/local/Cellar/maven/3.2.3/libexec
Java version: 1.7.0_25, vendor: Oracle Corporation
Java home:/Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.10.3", arch: "x86_64", family: "mac"

Update mvn clean verify -X output link.

like image 485
bhdrkn Avatar asked May 14 '15 08:05

bhdrkn


1 Answers

Please change your build section that way (without configuration tag):

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.18.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>integration-test</goal>
                        <goal>verify</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
like image 99
cslysy Avatar answered Sep 27 '22 20:09

cslysy