Skip to content

Commit

Permalink
(pom) reintroduce failsafe to run integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanlermitage committed Jan 22, 2020
1 parent 3d0e878 commit fafac63
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 100 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -50,7 +50,7 @@ Some experimentation with **Spring Boot 2**, JDK8+, JUnit5, TestNG, SQL (HSQLDB,
* Java **architecture tests** via [**ArchUnit**](https://github.com/TNG/ArchUnit). See last commit of [spring5-light-archunit](https://github.com/jonathanlermitage/manon/tree/spring5-light-archunit) branch
* use dockerized **MariaDB** on **[Travis](https://travis-ci.org/jonathanlermitage/manon)** CI instead of embedded HSQLDB. See last commit of [spring5-light-travis-with-mariadb](https://github.com/jonathanlermitage/manon/tree/spring5-light-travis-with-mariadb) branch
* use dockerized **PostgreSQL** on **[Travis](https://travis-ci.org/jonathanlermitage/manon)** CI. See last commit of [postgres](https://github.com/jonathanlermitage/manon/tree/postgres) branch
* **split Unit and Integration Tests**: run Unit Tests first and, if they don't fail, run Integration Tests. See last commit of [spring5-light-separate-integ-unit](https://github.com/jonathanlermitage/manon/tree/spring5-light-separate-integ-unit) branch. Due to JDK11+JUnit5+Failsafe issues ([that may be fixed in Failsafe 3.0.0](https://maven.apache.org/surefire/maven-failsafe-plugin/)), I run both Integration and Unit tests via Surefire Maven plugin
* ~~**split Unit and Integration Tests**: run Unit Tests first and, if they don't fail, run Integration Tests. See last commit of [spring5-light-separate-integ-unit](https://github.com/jonathanlermitage/manon/tree/spring5-light-separate-integ-unit) branch. Due to JDK11+JUnit5+Failsafe issues ([that may be fixed in Failsafe 3.0.0](https://maven.apache.org/surefire/maven-failsafe-plugin/)), I run both Integration and Unit tests via Surefire Maven plugin~~ I now use Surefire + Failsafe, and it works well (2020-01-22)
* **[Gatling](https://gatling.io) benchmark**. See last commit of [spring5-light-gatling](https://github.com/jonathanlermitage/manon/tree/spring5-light-gatling) branch and dedicated [README.md](docker/gatling/README.md) file
* **migration from MongoDB** (used to store regular and authentication data) to **MariaDB**. See last commit of [spring5-light-mongo-to-sql](https://github.com/jonathanlermitage/manon/tree/spring5-light-mongo-to-sql) branch
* tests work with an **embedded MongoDB** instance (for data) and HSQLDB (for Spring Batch internals only), that means you don't have to install any database to test project
Expand Down
2 changes: 1 addition & 1 deletion do
Expand Up @@ -116,7 +116,7 @@ for ((cmd = 1; cmd <= $#; cmd++)); do
;;

"itc")
sh ./mvnw verify -P coverage-it
sh ./mvnw verify -P coverage -DskipUT=true
;;

"b")
Expand Down
2 changes: 1 addition & 1 deletion do.cmd
Expand Up @@ -49,7 +49,7 @@ if [%1] == [tc] (
mvnw clean verify -P coverage
)
if [%1] == [itc] (
mvnw clean verify -P coverage-it
mvnw clean verify -P coverage -DskipUT=true
)
if [%1] == [b] (
mvnw clean compile -DskipUT=true -DskipIT=true -T1
Expand Down
110 changes: 13 additions & 97 deletions pom.xml
Expand Up @@ -496,40 +496,23 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
<skipTests>${skipUT}</skipTests>
<argLine>${surefireArgLine} ${surefireProfileArgLine} ${surefirePerformanceArgLine}</argLine>
<workingDirectory>${project.build.directory}</workingDirectory>
<!-- Prevent "Could not find or load main class ForkedBooter" issue. It may be fixed once surefire 3.0.0 is released. -->
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<skipTests>${skipIT}</skipTests>
<argLine>${surefireArgLine} ${surefireProfileArgLine} ${surefirePerformanceArgLine}</argLine>
<workingDirectory>${project.build.directory}</workingDirectory>
<!-- Prevent "Could not find or load main class ForkedBooter" issue. It may be fixed once surefire 3.0.0 is released. -->
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
<executions>
<execution>
<id>unit-tests</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skipTests>${skipUT}</skipTests>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
</execution>
<execution>
<id>integration-tests</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skipTests>${skipIT}</skipTests>
<includes>
<include>**/*IT.*</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
Expand Down Expand Up @@ -658,81 +641,14 @@
</argLine>
</configuration>
</plugin>
</plugins>
</build>
</profile>

<!-- Code coverage via JaCoCo on integration tests only. -->
<profile>
<id>coverage-it</id>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
<executions>
<execution>
<id>pre-integration-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/jacoco.exec</destFile>
<propertyName>coverageSurefireArgLine</propertyName>
</configuration>
</execution>
<execution>
<id>post-integration-test</id>
<phase>post-integration-test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/jacoco.exec</dataFile>
<outputDirectory>${project.reporting.outputDirectory}/jacoco</outputDirectory>
<excludes>
<exclude>manon/document/**</exclude>
<exclude>manon/model/**</exclude>
<exclude>manon/Application.*</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<argLine>${surefireArgLine} ${surefireProfileArgLine} ${surefirePerformanceArgLine}
@{coverageSurefireArgLine}
</argLine>
</configuration>
<executions>
<execution>
<id>unit-tests</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skipTests>true</skipTests>
</configuration>
</execution>
<execution>
<id>integration-tests</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skipTests>false</skipTests>
<includes>
<include>**/*IT.*</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Expand Down

0 comments on commit fafac63

Please sign in to comment.