4

I want to skip integration tests while running maven release plugin with command

mvn -B -DskipITs release:prepare release:perform

It does not seem to work this way. The same option -DskipITs works for mvn install/deploy. I don't want to use -Dmaven.test.skip=true since only integration tests need to be ignored, not unit tests. What is the best way to accomplish this?

EDIT: -Darguments=-DskipITs works for release:prepare, but surprising it does NOT work for release:perform. Tried -Darguments=-Dmaven.test.skip=true, does not work either.

Tried to add <arguments>skipITs</arguments> for release plugin in the pom, but it would ignore all other -Darguments provided in command line. I can't have everything configured in plugin config, since some of the options takes environment variables on the fly.

ddd
  • 4,665
  • 14
  • 69
  • 125

3 Answers3

8

According to how to make maven release plugin skip tests, it seems you need both -DskipITs and -Darguments=-DskipITs. One is to skip compiling ITs the other is for skipping running ITs.

peter.murray.rust
  • 37,407
  • 44
  • 153
  • 217
ddd
  • 4,665
  • 14
  • 69
  • 125
1

Use Maven Profiles.

Add the following to your pom:

<profiles>
    <profile>
        <id>ItsReleaseTime</id>
        <build>
        <plugins>
        <build> 
            <plugins> 
               <plugin>          
                   <groupId>org.apache.maven.plugins</groupId> 
                   <artifactId>maven-surefire-plugin</artifactId>
                   <version>2.20</version>    
                   <configuration>
                        <excludes>    
                              <exclude>**/*IT.java</exclude> 
                        </excludes> 
                   </configuration> 
               </plugin>
            </plugins>       
        </build>
    </profile>
</profiles>

And invoke the command :

mvn -B -P ItsReleaseTime release:prepare release:perform
Shailesh Pratapwar
  • 4,054
  • 3
  • 35
  • 46
  • Sorry this is simply wrong, cause maven-surefire-plugin is not responsible for running integration tests...and this naming schema is by default not used by maven-surefire-plugin. This is the naming schema from the maven-failsafe-plugin... – khmarbaise May 25 '17 at 15:42
-1

You can add some setting in your pm.xml file.

   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <version>2.12.4</version>
      <configuration>
         <skipTests>true</skipTests>
      </configuration>
   </plugin>
Ramesh KC
  • 570
  • 7
  • 30
  • I tried to avoid this, because most of the time tests will run. Only when it is being deployed in CICD pipeline. Plus wouldn't this skip unit tests as well? – ddd May 25 '17 at 15:03
  • The question was about skipping integration tests; not all tests – Viswanath Oct 08 '20 at 20:32