Skip to content

Commit

Permalink
Update the blog post and example application
Browse files Browse the repository at this point in the history
  • Loading branch information
pkainulainen committed Nov 29, 2014
1 parent bf0e06b commit 693fec6
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 30 deletions.
10 changes: 0 additions & 10 deletions integration-testing/README

This file was deleted.

12 changes: 12 additions & 0 deletions integration-testing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
This an example application of my blog post:

* [Integration Testing with Maven](http://www.petrikainulainen.net/programming/maven/integration-testing-with-maven/)

You can run unit tests by running the following command at the command prompt:

mvn clean test

You can run integration tests by running the following command at the command prompt:

mvn clean verify -P integration-test

100 changes: 80 additions & 20 deletions integration-testing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,46 @@
</license>
</licenses>
<properties>
<!-- Used to locate the profile specific configuration file. -->
<build.profile.id>dev</build.profile.id>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Only unit tests are run by default. -->
<skip.integration.tests>true</skip.integration.tests>
<skip.unit.tests>false</skip.unit.tests>
</properties>
<profiles>
<!-- The Configuration of the development profile -->
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!--
Specifies the build.profile.id property that must be equal than the name of
the directory that contains the profile specific configuration file.
Because the name of the directory that contains the configuration file of the
development profile is dev, we must set the value of the build.profile.id
property to dev.
-->
<build.profile.id>dev</build.profile.id>
<!--
Only unit tests are run when the development profile is active
-->
<skip.integration.tests>true</skip.integration.tests>
<skip.unit.tests>false</skip.unit.tests>
</properties>
</profile>
<!-- The Configuration of the integration-test profile -->
<profile>
<id>integration-test</id>
<properties>
<!-- Used to locate the profile specific configuration file. -->
<!--
Specifies the build.profile.id property that must be equal than the name of
the directory that contains the profile specific configuration file.
Because the name of the directory that contains the configuration file of the
integration-test profile is integration-test, we must set the value of the
build.profile.id property to integration-test.
-->
<build.profile.id>integration-test</build.profile.id>
<!-- Only integration tests are run. -->
<!--
Only integration tests are run when the integration-test profile is active
-->
<skip.integration.tests>false</skip.integration.tests>
<skip.unit.tests>true</skip.unit.tests>
</properties>
Expand All @@ -40,66 +63,103 @@
<build>
<finalName>maven-integration-testing</finalName>
<filters>
<!--
Ensures that the config.properties file is always loaded from the
configuration directory of the active Maven profile.

-->
<filter>profiles/${build.profile.id}/config.properties</filter>
</filters>
<resources>
<!--
Placeholders that are found from the files located in the configured resource
directories are replaced with the property values found from the profile
specific configuration file.
-->
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<!-- Used to add source directories to our build. -->
<!-- Adds source and resource directories to our build -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<version>1.9.1</version>
<executions>
<!-- States that the plugin's add-test-source goal is executed at generate-test-sources phase. -->
<!-- Add a new source directory to our build -->
<execution>
<id>add-integration-test-sources</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<!-- Configures the source directory of integration tests. -->
<!-- Configures the source directory of our integration tests -->
<sources>
<source>src/integration-test/java</source>
</sources>
</configuration>
</execution>
<!-- Add a new resource directory to our build -->
<execution>
<id>add-integration-test-resources</id>
<phase>generate-test-resources</phase>
<goals>
<goal>add-test-resource</goal>
</goals>
<configuration>
<!-- Configures the resource directory of our integration tests -->
<resources>
<!--
Placeholders that are found from the files located in the configured resource
directories are replaced with the property values found from the profile
specific configuration file.
-->
<resource>
<filtering>true</filtering>
<directory>src/integration-test/resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<!-- Used for unit tests -->
<!-- Runs unit tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<version>2.18</version>
<configuration>
<!-- Skips unit tests if the value of skip.unit.tests property is true -->
<skipTests>${skip.unit.tests}</skipTests>
<!-- Excludes integration tests when unit tests are run. ß-->
<!-- Excludes integration tests when unit tests are run -->
<excludes>
<exclude>**/IT*.java</exclude>
</excludes>
</configuration>
</plugin>
<!-- Used for integration tests -->
<!-- Runs integration tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.12</version>
<version>2.18</version>
<executions>
<!-- States that both integration-test and verify goals of the Failsafe Maven plugin are executed. -->
<!--
Invokes both the integration-test and the verify goals of the
Failsafe Maven plugin
-->
<execution>
<id>integration-tests</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<!-- Skips integration tests if the value of skip.integration.tests property is true -->
<!--
Skips integration tests if the value of skip.integration.tests
property is true
-->
<skipTests>${skip.integration.tests}</skipTests>
</configuration>
</execution>
Expand All @@ -109,7 +169,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<version>3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
Expand All @@ -119,7 +179,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<version>2.7</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
profile=${profile}

0 comments on commit 693fec6

Please sign in to comment.