title: Integration test with maven
body: <p>I want to be able to run Unit tests and integration tests separately.</p>
  
  <p>The problem is that even though from my child pom.xml I specify that, when I run:</p>
  
  <pre><code>mvn verify -P integration-test
  </code></pre>
  
  <p>I want to just run the tests in <code>src/it/java</code>, but it just executes all the tests. </p>
  
  <p>My directories are:</p>
  
  <pre><code>edms-pro
    pom.xml (the general one)
    ...
    rest-servides
      src
        it
          java
          resources
      pom.xml (the child one)
  </code></pre>
  
  <p><strong>pom.xml</strong> (the child one)</p>
  
  <pre><code>&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;groupId&gt;com.everis&lt;/groupId&gt;
      &lt;artifactId&gt;edms-pro&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;/parent&gt;
  
    &lt;name&gt;Big Content Services&lt;/name&gt;
  
    &lt;artifactId&gt;rest-services&lt;/artifactId&gt;
    &lt;packaging&gt;jar&lt;/packaging&gt;
  
    &lt;properties&gt;
      &lt;skip.unit.tests&gt;false&lt;/skip.unit.tests&gt;
      &lt;skip.integration.tests&gt;true&lt;/skip.integration.tests&gt;
    &lt;/properties&gt;
  
    &lt;profiles&gt;
      &lt;profile&gt;
        &lt;id&gt;dev&lt;/id&gt;
        &lt;activation&gt;
          &lt;activeByDefault&gt;true&lt;/activeByDefault&gt;
        &lt;/activation&gt;
      &lt;/profile&gt;
      &lt;profile&gt;
        &lt;id&gt;integration-test&lt;/id&gt;
        &lt;properties&gt;
          &lt;!--
              Only integration tests are run when the integration-test profile is active
          --&gt;
          &lt;skip.integration.tests&gt;false&lt;/skip.integration.tests&gt;
          &lt;skip.unit.tests&gt;true&lt;/skip.unit.tests&gt;
        &lt;/properties&gt;
      &lt;/profile&gt;
    &lt;/profiles&gt;
  
    &lt;dependencies&gt;
      &lt;!-- Spring components --&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
        &lt;exclusions&gt;
          &lt;exclusion&gt;
            &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
            &lt;artifactId&gt;log4j-over-slf4j&lt;/artifactId&gt;
          &lt;/exclusion&gt;
        &lt;/exclusions&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-starter-security&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-starter-actuator&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;io.prometheus&lt;/groupId&gt;
        &lt;artifactId&gt;simpleclient_spring_boot&lt;/artifactId&gt;
        &lt;version&gt;${prometheus.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;io.prometheus&lt;/groupId&gt;
        &lt;artifactId&gt;simpleclient_hotspot&lt;/artifactId&gt;
        &lt;version&gt;${prometheus.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;com.ryantenney.metrics&lt;/groupId&gt;
        &lt;artifactId&gt;metrics-spring&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;io.springfox&lt;/groupId&gt;
        &lt;artifactId&gt;springfox-swagger2&lt;/artifactId&gt;
        &lt;version&gt;${swagger2.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;io.springfox&lt;/groupId&gt;
        &lt;artifactId&gt;springfox-swagger-ui&lt;/artifactId&gt;
        &lt;version&gt;${swagger2.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
        &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;!-- Lombok Java extensions --&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
        &lt;artifactId&gt;lombok&lt;/artifactId&gt;
        &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;!-- Apache Commons --&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;commons-io&lt;/groupId&gt;
        &lt;artifactId&gt;commons-io&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.apache.commons&lt;/groupId&gt;
        &lt;artifactId&gt;commons-lang3&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;!-- JSR-305 annotations for Software Defect Detection --&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;com.google.code.findbugs&lt;/groupId&gt;
        &lt;artifactId&gt;jsr305&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;!-- Google Guava core libraries for Java --&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;com.google.guava&lt;/groupId&gt;
        &lt;artifactId&gt;guava&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;!-- Logging --&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;net.logstash.logback&lt;/groupId&gt;
        &lt;artifactId&gt;logstash-logback-encoder&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;!-- Apache http components --&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.apache.httpcomponents&lt;/groupId&gt;
        &lt;artifactId&gt;httpmime&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;!-- Testing --&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;junit&lt;/groupId&gt;
        &lt;artifactId&gt;junit&lt;/artifactId&gt;
        &lt;scope&gt;test&lt;/scope&gt;
        &lt;exclusions&gt;
          &lt;exclusion&gt;
            &lt;groupId&gt;org.hamcrest&lt;/groupId&gt;
            &lt;artifactId&gt;hamcrest-core&lt;/artifactId&gt;
          &lt;/exclusion&gt;
        &lt;/exclusions&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.hamcrest&lt;/groupId&gt;
        &lt;artifactId&gt;hamcrest-library&lt;/artifactId&gt;
        &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.assertj&lt;/groupId&gt;
        &lt;artifactId&gt;assertj-core&lt;/artifactId&gt;
        &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;com.everis&lt;/groupId&gt;
        &lt;artifactId&gt;edms-mocks&lt;/artifactId&gt;
        &lt;version&gt;${com.everis.edms.version}&lt;/version&gt;
        &lt;scope&gt;test&lt;/scope&gt;
        &lt;exclusions&gt;
          &lt;exclusion&gt;
            &lt;groupId&gt;com.everis&lt;/groupId&gt;
            &lt;artifactId&gt;edms-backend-couchbase&lt;/artifactId&gt;
          &lt;/exclusion&gt;
        &lt;/exclusions&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.json&lt;/groupId&gt;
        &lt;artifactId&gt;json&lt;/artifactId&gt;
        &lt;version&gt;20160810&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;com.auth0&lt;/groupId&gt;
        &lt;artifactId&gt;java-jwt&lt;/artifactId&gt;
        &lt;version&gt;3.1.0&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;com.microsoft.azure&lt;/groupId&gt;
        &lt;artifactId&gt;adal4j&lt;/artifactId&gt;
        &lt;version&gt;1.1.2&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
        &lt;artifactId&gt;spring-security-test&lt;/artifactId&gt;
        &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;com.everis&lt;/groupId&gt;
        &lt;artifactId&gt;multitenancy-test&lt;/artifactId&gt;
        &lt;version&gt;${com.everis.edms.version}&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.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
          &lt;configuration&gt;
            &lt;classifier&gt;${dist.classifier}&lt;/classifier&gt;
          &lt;/configuration&gt;
        &lt;/plugin&gt;
        &lt;!-- A partir d'aqui afegir per Hector respecte diseny original--&gt;
        &lt;plugin&gt;
          &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
          &lt;artifactId&gt;build-helper-maven-plugin&lt;/artifactId&gt;
          &lt;!--&lt;version&gt;1.12&lt;/version&gt; --&gt;
          &lt;executions&gt;
            &lt;execution&gt;
              &lt;id&gt;add-integration-test-sources&lt;/id&gt;
              &lt;phase&gt;generate-test-sources&lt;/phase&gt;
              &lt;goals&gt;
                &lt;goal&gt;add-test-source&lt;/goal&gt;
              &lt;/goals&gt;
              &lt;configuration&gt;
                &lt;!-- Configures the source directory of our integration tests --&gt;
                &lt;sources&gt;
                  &lt;source&gt;src/it/java&lt;/source&gt;
                &lt;/sources&gt;
              &lt;/configuration&gt;
            &lt;/execution&gt;
            &lt;!-- Add a new resource directory to our build --&gt;
            &lt;execution&gt;
              &lt;id&gt;add-integration-test-resources&lt;/id&gt;
              &lt;phase&gt;generate-test-resources&lt;/phase&gt;
              &lt;goals&gt;
                &lt;goal&gt;add-test-resource&lt;/goal&gt;
              &lt;/goals&gt;
              &lt;configuration&gt;
                &lt;!-- Configures the resource directory of our integration tests --&gt;
                &lt;resources&gt;
                  &lt;resource&gt;
                    &lt;filtering&gt;true&lt;/filtering&gt;
                    &lt;directory&gt;src/it/resources&lt;/directory&gt;
                  &lt;/resource&gt;
                &lt;/resources&gt;
              &lt;/configuration&gt;
            &lt;/execution&gt;
          &lt;/executions&gt;
        &lt;/plugin&gt;
        &lt;plugin&gt;
          &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
          &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
          &lt;!--&lt;version&gt;3.5&lt;/version&gt; --&gt;
          &lt;configuration&gt;
            &lt;!--&lt;source&gt;${jdk.version}&lt;/source&gt;
            &lt;target&gt;${jdk.version}&lt;/target&gt; --&gt;
            &lt;encoding&gt;${project.build.sourceEncoding}&lt;/encoding&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;!--&lt;version&gt;2.19.1&lt;/version&gt; --&gt;
          &lt;configuration&gt;
            &lt;!--&lt;groups&gt;com.testwithspring.intermediate.unittests.UnitTest&lt;/groups&gt;--&gt;
            &lt;!--
                Skips unit tests if the value of skip.unit.tests
                property is true
            --&gt;
            &lt;skipTests&gt;${skip.unit.tests}&lt;/skipTests&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;${maven-failsafe-plugin.version}&lt;/version&gt;
          &lt;executions&gt;
            &lt;execution&gt;
              &lt;!--&lt;id&gt;integration-tests&lt;/id&gt;--&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;testSourceDirectory&gt;src/it/java&lt;/testSourceDirectory&gt;
                &lt;!--
                &lt;includes&gt;
                  &lt;include&gt;src/it/*.java&lt;/include&gt;
                &lt;/includes&gt; --&gt;
                &lt;!--&lt;groups&gt;com.testwithspring.intermediate.integrationtests.IntegrationTest&lt;/groups&gt;--&gt;
                &lt;!--
                    Skips integration tests if the value of skip.integration.tests
                    property is true
                --&gt;
                &lt;skipTests&gt;${skip.integration.tests}&lt;/skipTests&gt;
              &lt;/configuration&gt;
            &lt;/execution&gt;
          &lt;/executions&gt;
        &lt;/plugin&gt;
      &lt;/plugins&gt;
    &lt;/build&gt;
  
  &lt;/project&gt; 
  </code></pre>
  
  <p>I run <code>mvn verify -P integration-test</code> from the main directory and I would like just to test the scripts inside the folders called "it".    </p>