I´m using a ScalaTest plugin to execute some IT test. I need to skip all the test(Unit, IT
) in some pipelines, and they only use the flag ${skipTests}
so I need to use that flag for all my types of testing. In local sometimes I want just to execute, unit or IT test, but now having only one flag it´s not possible.
Only comment the line in the plugin of the IT it would works but I dont like this error prone aproach(Someone will commit the comment line for sure)
<skipTests>${skipTests}</skipTests>
I was thinking that it would be great if I can use some sort of OR
condition to set a new flag in my local executions as true and keep the other as false
<skipTests>${skipTests} || ${skipItTests}</skipTests>
Obviously this is not working, but I was wondering if someone know a way to do what I want.
Regards.
It has been already answered in Prevent unit tests but allow integration tests in Maven
At glance you can use following pom snippet for being able running any combination of (UNIT, IT) tests.
<project>
...
<properties>
<skipTests>false</skipTests>
<skipITs>${skipTests}</skipITs>
<skipUTs>${skipTests}</skipUTs>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.12.4</version> <!-- use appropriate version -->
<configuration>
<skipTests>${skipTests}</skipTests>
<skipITs>${skipITs}</skipITs>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version> <!-- use appropriate version -->
<configuration>
<skipTests>${skipUTs}</skipTests>
</configuration>
</plugin>
</plugins>
</build>
</project>
And use
mvn install -DskipUTs
: Skips Unit testsmvn install -DskipITs
: Skips Integration testsmvn install -DskipTests
: Skips both Unit and Integration TestsOriginal post is https://antoniogoncalves.org/2012/12/13/lets-turn-integration-tests-with-maven-to-a-first-class-citizen/