title: Maven separate Unit Test and Integration Tests
body: <p>UT = Unit Tests
  IT = Integration Tests. All my Integration test classes are annotated with @Category(IntegrationTest.class)  </p>
  
  <p>My goal is:</p>
  
  <p><code>mvn clean install</code> => runs UT and not IT</p>
  
  <p><code>mvn clean install</code> -DskipTests=true => no tests are executed</p>
  
  <p><code>mvn clean deploy</code> => runs UT and not IT</p>
  
  <p><code>mvn clean test</code> => runs UT and not IT</p>
  
  <p><code>mvn clean verify</code> => runs UT and IT</p>
  
  <p><code>mvn clean integration-test</code> => runs IT and UT are not executed</p>
  
  <p><code>mvn clean install deploy</code> => runs UT and not IT</p>
  
  <p>pom properties:</p>
  
  <pre><code>&lt;junit.version&gt;4.12&lt;/junit.version&gt;
  &lt;surefire-plugin.version&gt;2.18.1&lt;/surefire-plugin.version&gt;
  &lt;failsafe-plugin.version&gt;2.18.1&lt;/failsafe-plugin.version&gt;
  </code></pre>
  
  <ol>
  <li><p>Compiler:</p>
  
  <pre><code>&lt;plugin&gt;
      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
      &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
      &lt;version&gt;2.5.1&lt;/version&gt;
      &lt;configuration&gt;
          &lt;source&gt;1.8&lt;/source&gt;
          &lt;target&gt;1.8&lt;/target&gt;
          &lt;compilerArgument&gt;-Xlint:all&lt;/compilerArgument&gt;
          &lt;showWarnings&gt;true&lt;/showWarnings&gt;
          &lt;showDeprecation&gt;true&lt;/showDeprecation&gt;
      &lt;/configuration&gt;
  &lt;/plugin&gt;
  </code></pre></li>
  <li><p>Unit Tests:</p>
  
  <pre><code>&lt;plugin&gt;
      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
      &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
      &lt;version&gt;${surefire-plugin.version}&lt;/version&gt;
      &lt;configuration&gt;
          &lt;excludedGroups&gt;com.xpto.IntegrationTest&lt;/excludedGroups&gt;
      &lt;/configuration&gt;
  &lt;/plugin&gt;
  </code></pre></li>
  <li><p>Integration Tests:</p>
  
  <pre><code>&lt;plugin&gt;
      &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
      &lt;artifactId&gt;maven-failsafe-plugin&lt;/artifactId&gt;
      &lt;version&gt;${failsafe-plugin.version}&lt;/version&gt;
      &lt;configuration&gt;
          &lt;groups&gt;com.xpto.IntegrationTest&lt;/groups&gt;
      &lt;/configuration&gt;
      &lt;executions&gt;
          &lt;execution&gt;
              &lt;goals&gt;
                  &lt;goal&gt;integration-test&lt;/goal&gt;
              &lt;/goals&gt;
              &lt;configuration&gt;
                  &lt;includes&gt;
                      &lt;include&gt;**/*.class&lt;/include&gt;
                  &lt;/includes&gt;
              &lt;/configuration&gt;
          &lt;/execution&gt;                
      &lt;/executions&gt;              
  &lt;/plugin&gt;        
  </code></pre></li>
  </ol>
  
  <p>My results are:</p>
  
  <p><code>mvn clean install</code> => OK</p>
  
  <p><code>mvn clean install</code> -DskipTests=true => OK</p>
  
  <p><code>mvn clean deploy</code> => runs UT and not IT</p>
  
  <p><code>mvn clean test</code> => OK</p>
  
  <p><code>mvn clean verify</code> => NOK ... only UT are executed but IT also needs to be executed</p>
  
  <p><code>mvn clean integration-test</code> => NOK ... UT are executed and should not and IT aren't executed but should be executed</p>
  
  <p><code>mvn clean install deploy</code> => OK</p>