title: How does Maven different unit Test from integration Test?
body: <p>This is my project structure in <code>mvn</code>:</p>
  
  <p><img src="https://i.stack.imgur.com/lww61.png" alt="enter image description here"></p>
  
  <p>As you can notice, I have two classes in <code>src/test/java</code></p>
  
  <ol>
  <li><p><code>CardValidtorIT.java</code> (THis is integration test)</p></li>
  <li><p><code>CardValidatorTest.java</code>  (This is Unit-Test)</p></li>
  </ol>
  
  <p>when I run </p>
  
  <p><code>mvn package</code></p>
  
  <p>I notice only the <code>unit-test (CardValidatorTest.java)</code> is run</p>
  
  <p>But when I run</p>
  
  <p><code>mvn integration-test</code></p>
  
  <p>I see both <code>unit-test</code> and <code>Integration tests</code> are run.</p>
  
  <p>How does <code>mvn</code> know not to execute the <code>CardValidatorIT.java</code> when I run <code>mvn package</code>. That is, why it did not run <code>CardValidatoryIT.java</code></p>
  
  <p>Here is my <code>pom.xml</code></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0  http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;parent&gt;
      &lt;artifactId&gt;chapter14&lt;/artifactId&gt;
      &lt;groupId&gt;org.agoncal.book.javaee7&lt;/groupId&gt;
      &lt;version&gt;1.0&lt;/version&gt;
  &lt;/parent&gt;
  &lt;groupId&gt;org.agoncal.book.javaee7.chapter14&lt;/groupId&gt; &lt;artifactId&gt;chapter14-service&lt;/artifactId&gt; &lt;version&gt;1.0&lt;/version&gt;
  &lt;packaging&gt;war&lt;/packaging&gt;
    &lt;dependencies&gt;
      &lt;dependency&gt;
  &lt;groupId&gt;org.glassfish.main.extras&lt;/groupId&gt; &lt;artifactId&gt;glassfish-embedded-all&lt;/artifactId&gt; &lt;version&gt;4.0&lt;/version&gt;
  &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;junit&lt;/groupId&gt;
        &lt;artifactId&gt;junit&lt;/artifactId&gt;
        &lt;version&gt;4.11&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
    &lt;/dependencies&gt;
    &lt;build&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;version&gt;2.5.1&lt;/version&gt;
          &lt;configuration&gt;
            &lt;source&gt;1.7&lt;/source&gt;
            &lt;target&gt;1.7&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-war-plugin&lt;/artifactId&gt;
          &lt;version&gt;2.2&lt;/version&gt;
          &lt;configuration&gt;
            &lt;failOnMissingWebXml&gt;false&lt;/failOnMissingWebXml&gt;
          &lt;/configuration&gt;
        &lt;/plugin&gt;
        &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;2.12.4&lt;/version&gt;
  &lt;executions&gt;
            &lt;execution&gt;
              &lt;id&gt;integration-test&lt;/id&gt;
              &lt;goals&gt;
  &lt;goal&gt;integration-test&lt;/goal&gt;
                &lt;goal&gt;verify&lt;/goal&gt;
              &lt;/goals&gt;
            &lt;/execution&gt;
          &lt;/executions&gt;
        &lt;/plugin&gt;
      &lt;/plugins&gt;
    &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>P.S: I do know that I have a <code>integration-test</code> goal in mvn. but I have not tied the goal to which class should be run during integration test</p>
  
  <p>Thanks</p>