title: Maven surefire tests - includes and excludes
body: <p>I have a class <strong>A.java</strong> and two test classes, <strong>ATest.java</strong> and <strong>AITests.java</strong>. The ITest is for integration. The tests must be performed as:</p>
  
  <ol>
  <li><p>When no Maven profile is selected only the Atest must be tested.</p></li>
  <li><p>When the <strong>itests</strong> profile is activated the both tests (ATest and AITest) must be tested.</p></li>
  </ol>
  
  <p>The problems is, when I use the command</p>
  
  <pre><code>mvn -P itests test
  </code></pre>
  
  <p>then only the ATest is tested, without the AITest. But I have no idea what I am missing here. Any hint?</p>
  
  <p>My <strong>pom.xml</strong> is:</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;version&gt;3.0.0-M4&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;excludes&gt;
                      &lt;exclude&gt;**/*ITest.java&lt;/exclude&gt;
                  &lt;/excludes&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  
  &lt;profiles&gt;
      &lt;profile&gt;
          &lt;id&gt;itests&lt;/id&gt;
          &lt;activation&gt;
              &lt;property&gt;
                  &lt;name&gt;itests&lt;/name&gt;
                  &lt;value&gt;true&lt;/value&gt;
              &lt;/property&gt;
          &lt;/activation&gt;
          &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;version&gt;3.0.0-M4&lt;/version&gt;
                      &lt;configuration&gt;
                          &lt;includes&gt;
                              &lt;include&gt;**/*Test.java&lt;/include&gt;
                          &lt;/includes&gt;
                      &lt;/configuration&gt;
                  &lt;/plugin&gt;
              &lt;/plugins&gt;
          &lt;/build&gt;
      &lt;/profile&gt;
  &lt;/profiles&gt;
  ...
  </code></pre>