Showing posts with label Build. Show all posts
Showing posts with label Build. Show all posts

24 March, 2015

How to skip integration test in maven build ?

Its not so easy when I was trying with all the possible and lost my 3 hours of valuable time. Its really very pathetic when you are trying to do something and its not happening within your time period....

This happens me when I was trying to build without the integration tests only. My scenario was to skip only integration tests ,but it must execute the unit test cases. I gooooogle almost many links but no luck , but finally the luck clicks and it works for me with below pom.xml configuration.


Add the below tag into you pom.xml


<build>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<excludes>
<exclude>**/*IntegrationTest.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>



Here you can use <exclude> tag and mentioned any test class you want to skip.If your java class name contains *ITest.java (i.e. MyMethodITest.java)

<exclude>**/*IT*.java</exclude>

or 

<exclude>**/*AnyTestClasses.java</exclude>



Not only integration test you can skip any classes over here, but you need to configure the pom.xml properly.And in the maven command you can use below command as normal (i.e. mvn clean install)


Note - Be careful about the version, because it may not work for all version.

I hope it will help you all.



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 -