20 December, 2014

How to skip test case in Maven build ?

You can skip the test in two following ways :-

By configuring the Pom.xml , if you are using surefire plugin then you can configure as below. 


<build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.18</version>
        <configuration>
          <skipTests>true</skipTests>
        </configuration>
      </plugin>
    </plugins>

  </build>

For specific module test you can create profile in pom.xml for specific environment and it will help to skip the test cases.You can skip this specified profile "noTest".


<profiles>
    <profile>
      <id>noTest</id>
      <activation>
        <property>
          <name>noTest</name>
          <value>true</value>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.4.2</version>
            <configuration>
              <skipTests>true</skipTests>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>


By using Command Line :- 


1) -Dmaven.test.skip=true

2) -DskipTests ( The values can be true/false) 

Example - 


1 ) mvn clean install -DskipTests=true

2 ) mvn clean install -Dmaven.test.skip=true

 

Hope it will help you.

Follow for more details on Google+ and @Facebook!!!


Find More Solutions -

No comments:

Post a Comment