0

I've a maven project which use surefire plugin for both unit tests and integration tests. Is there a maven command that I can use just to skip the unit tests but to run integration tests.

I've tried mvn clean install -DskipUnitTests but that is not working

4
  • 1
    Why not correctly using maven-surefire-plugin for unit tests and maven-failsafe-plugin for integration tests. This separation is causing your problems.. Commented May 8, 2015 at 11:06
  • Do you consider to use Failsafe plugin with the integration tests? Commented May 8, 2015 at 11:06
  • @khmarbaise Yes I agree. But it take lot of effort since the project contains number of modules Commented May 8, 2015 at 11:07
  • 1
    Sure but it should be separated anyway so just take the chance to cleanup the project. Separation of unit and integration tests is very important. Running unit tests and integration tests separately as you already like to do. This would make life easy. Commented May 9, 2015 at 7:56

2 Answers 2

2

I would say: no.

But I recommend you the failsafe plugin solution. Some refactoring/renaming, and you can test.

See here my answer, it could help you: How can I fire integration tests separately using failsafe-plugin?

Sign up to request clarification or add additional context in comments.

Comments

1

run this command:mvn verify -Dtest=!*Test -DfailIfNoTests=false Below is my 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.aaa</groupId> <artifactId>IntegrationTestMaven</artifactId> <version>0.0.1-SNAPSHOT</version> <name>IntegrationTestMaven</name> <!-- <properties> Only unit tests are run by default. <skip.integration.tests>true</skip.integration.tests> <skip.unit.tests>false</skip.unit.tests> </properties> --> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <version>1.5</version> <executions> <execution> <id>add-test-source</id> <phase>process-resources</phase> <goals> <goal>add-test-source</goal> </goals> <configuration> <sources> <source>src/integrationtest/java</source> </sources> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.15</version> <configuration> <!-- Skips unit tests if the value of skip.unit.tests property is true --> <!-- Excludes integration tests when unit tests are run. --> <excludes> <exclude>**/*IT.java</exclude> </excludes> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <version>2.15</version> <executions> <execution> <id>integration-test</id> <goals> <goal>integration-test</goal> </goals> </execution> <execution> <id>verify</id> <goals> <goal>verify</goal> </goals> <configuration> <!-- Skips integration tests if the value of skip.integration.tests property is true --> <!-- <skipTests>${skip.integration.tests}</skipTests> --> <includes> <include>**/*IT.java</include> </includes> </configuration> </execution> </executions> </plugin> </plugins> </build> <!-- <profiles> <profile> <id>all-tests</id> <properties> <build.profile.id>all-tests</build.profile.id> All tests are run. <skip.integration.tests>false</skip.integration.tests> <skip.unit.tests>false</skip.unit.tests> </properties> </profile> <profile> <id>dev</id> </profile> <profile> <id>integration-tests</id> <properties> Used to locate the profile specific configuration file. <build.profile.id>integration-test</build.profile.id> Only integration tests are run. <skip.integration.tests>false</skip.integration.tests> <skip.unit.tests>true</skip.unit.tests> </properties> </profile> </profiles> --> </project>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.