title: How can I skip tests in maven install goal, while running them in maven test goal?
body: <p>I have a multi-module maven project with both integration and unit tests in the same folder (src/test/java). Integration tests are marked with <code>@Category(IntegrationTest.class)</code>. I want to end up with the following setup:</p>
  
  <ol>
  <li>If I run <code>mvn install</code>, I want all tests to compile, but I do not want to execute any.</li>
  <li>If I run <code>mvn test</code>, I want all tests to compile, but execute only unit tests.</li>
  <li>If I run <code>mvn integration-test</code>, I want to compile and execute all tests.</li>
  </ol>
  
  <p><strong>The important point is, I want this configured in the <code>pom.xml</code> without any extra commandline arguments.</strong></p>
  
  <p>Currently I came up with the following setup in my parent pom.xml, where the only problem is #1, where all tests are executed:</p>
  
  <pre><code>&lt;build&gt;
      &lt;pluginManagement&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                  &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                  &lt;configuration&gt;
                      &lt;source&gt;${project.java.version}&lt;/source&gt;
                      &lt;target&gt;${project.java.version}&lt;/target&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
  
              &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;2.14.1&lt;/version&gt;
                  &lt;dependencies&gt;
                      &lt;dependency&gt;
                          &lt;groupId&gt;org.apache.maven.surefire&lt;/groupId&gt;
                          &lt;artifactId&gt;surefire-junit47&lt;/artifactId&gt;
                          &lt;version&gt;2.14.1&lt;/version&gt;
                      &lt;/dependency&gt;
                  &lt;/dependencies&gt;
                  &lt;configuration&gt;
                      &lt;includes&gt;
                          &lt;include&gt;**/*.class&lt;/include&gt;
                      &lt;/includes&gt;
                      &lt;excludedGroups&gt;cz.cuni.xrg.intlib.commons.IntegrationTest&lt;/excludedGroups&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
  
              &lt;plugin&gt;
                  &lt;artifactId&gt;maven-failsafe-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.14.1&lt;/version&gt;
                  &lt;dependencies&gt;
                      &lt;dependency&gt;
                          &lt;groupId&gt;org.apache.maven.surefire&lt;/groupId&gt;
                          &lt;artifactId&gt;surefire-junit47&lt;/artifactId&gt;
                          &lt;version&gt;2.14.1&lt;/version&gt;
                      &lt;/dependency&gt;
                  &lt;/dependencies&gt;
                  &lt;configuration&gt;
                      &lt;groups&gt;cz.cuni.xrg.intlib.commons.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;goal&gt;verify&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;
          &lt;/plugins&gt;
      &lt;/pluginManagement&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p>All child modules have the following plugin configuration in their pom.xml, which I believe should inherit from the parent pom:</p>
  
  <pre><code>&lt;build&gt; 
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
          &lt;/plugin&gt;
  
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-failsafe-plugin&lt;/artifactId&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p>I tried using <code>&lt;skipTests&gt;true&lt;/skipTests&gt;</code>, but it disables test execution for all goals, which is not what I want (violates #2 and #3). It is also quite weird, that <code>mvn test</code> honors the <code>skipTests=true</code> option...why would I want to run it in the first place??</p>
  
  <p>After hours of googling and trying different combinations, I am hesitant whether it is even possible to not run tests in <code>mvn install</code>, while at the same time run them in <code>mvn test</code>. I hope someone proves this wrong. ;)</p>
  
  <p>I am also willing to accept a solution, where <code>mvn install</code> would execute only unit tests, but I don't think it makes much difference.</p>