Last active
February 7, 2018 09:41
-
-
Save delor/5916802 to your computer and use it in GitHub Desktop.
Minimal Maven configuration separating unit and integration tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mvn verify | |
[INFO] Scanning for projects... | |
[INFO] | |
[INFO] ------------------------------------------------------------------------ | |
[INFO] Building maven-tests-config 1.0-SNAPSHOT | |
[INFO] ------------------------------------------------------------------------ | |
[INFO] | |
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ maven-tests-config --- | |
[debug] execute contextualize | |
[INFO] Using 'UTF-8' encoding to copy filtered resources. | |
[INFO] Copying 0 resource | |
[INFO] | |
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ maven-tests-config --- | |
[INFO] Nothing to compile - all classes are up to date | |
[INFO] | |
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ maven-tests-config --- | |
[debug] execute contextualize | |
[INFO] Using 'UTF-8' encoding to copy filtered resources. | |
[INFO] skip non existing resourceDirectory /home/delor/code/maven-tests-config/unit-integration-tests-separation/src/test/resources | |
[INFO] | |
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ maven-tests-config --- | |
[INFO] Nothing to compile - all classes are up to date | |
[INFO] | |
[INFO] --- maven-surefire-plugin:2.15:test (default-test) @ maven-tests-config --- | |
[INFO] Surefire report directory: /home/delor/code/maven-tests-config/unit-integration-tests-separation/target/surefire-reports | |
------------------------------------------------------- | |
T E S T S | |
------------------------------------------------------- | |
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on | |
Running ExampleTest | |
Configuring TestNG with: TestNG652Configurator | |
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.32 sec - in ExampleTest | |
Results : | |
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 | |
[INFO] | |
[INFO] --- maven-jar-plugin:2.3.2:jar (default-jar) @ maven-tests-config --- | |
[INFO] Building jar: /home/delor/code/maven-tests-config/unit-integration-tests-separation/target/maven-tests-config-1.0-SNAPSHOT.jar | |
[INFO] | |
[INFO] --- maven-failsafe-plugin:2.15:integration-test (default) @ maven-tests-config --- | |
[INFO] Failsafe report directory: /home/delor/code/maven-tests-config/unit-integration-tests-separation/target/failsafe-reports | |
------------------------------------------------------- | |
T E S T S | |
------------------------------------------------------- | |
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on | |
Running ExampleIT | |
Configuring TestNG with: TestNG652Configurator | |
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.241 sec - in ExampleIT | |
Results : | |
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 | |
[INFO] | |
[INFO] --- maven-failsafe-plugin:2.15:verify (default) @ maven-tests-config --- | |
[INFO] Failsafe report directory: /home/delor/code/maven-tests-config/unit-integration-tests-separation/target/failsafe-reports | |
[INFO] ------------------------------------------------------------------------ | |
[INFO] BUILD SUCCESS | |
[INFO] ------------------------------------------------------------------------ | |
[INFO] Total time: 2.011s | |
[INFO] Finished at: Wed Jul 03 12:14:37 CEST 2013 | |
[INFO] Final Memory: 9M/148M | |
[INFO] ------------------------------------------------------------------------ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<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"> | |
<modelVersion>4.0.0</modelVersion> | |
<prerequisites> | |
<maven>2.2.1</maven> | |
</prerequisites> | |
<groupId>pl.delor.example</groupId> | |
<artifactId>maven-tests-config</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
<properties> | |
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | |
<skipTests>false</skipTests> | |
<skipITs>${skipTests}</skipITs> | |
<skipUTs>${skipTests}</skipUTs> | |
</properties> | |
<dependencies> | |
<dependency> | |
<groupId>org.testng</groupId> | |
<artifactId>testng</artifactId> | |
<version>6.8.7</version> | |
</dependency> | |
<dependency> | |
<groupId>org.easytesting</groupId> | |
<artifactId>fest-assert</artifactId> | |
<version>1.4</version> | |
</dependency> | |
</dependencies> | |
<build> | |
<plugins> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-surefire-plugin</artifactId> | |
<version>2.16</version> | |
<configuration> | |
<skipTests>${skipUTs}</skipTests> | |
</configuration> | |
</plugin> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-failsafe-plugin</artifactId> | |
<version>2.16</version> | |
<configuration> | |
<skipTests>${skipTests}</skipTests> | |
<skipITs>${skipITs}</skipITs> | |
</configuration> | |
<executions> | |
<execution> | |
<goals> | |
<goal>integration-test</goal> | |
<goal>verify</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
By default surefire configuration includes tests matching "/Test*.java", "/_Test.java" or "/_TestCase.java" pattern.
By default failsafe configuration includes tests matching "/IT*.java", "/_IT.java" or "/_ITCase.java" pattern.
Usage:
mvn install -DskipUTs : Skips Unit tests
mvn install -DskipITs : Skips Integration tests
mvn install -DskipTests : Skips both Unit and Integration Tests