Do you try to build your app after the slightest change in code, and it takes ages to pass all the tests? What if there would be a workaround to obey all unnecessary tests and shorten the Maven build time significantly. And all that just but simple maven flag.
Either you want to build you SpringBoot app into the executable JAR file or build classes for a package, remember to use single Maven flag parameter
mvn install -DskipTests and in the most of the cases you will be fine.
However, the rabbit might run deeper, so it will be better to write a bit more info.
-DskipTests option only works from Surefire 2.4. Unfortunately, there are no error messages if you do try to use it with Surefire 2.3 or lower. Therefore, your first task is to check your version of Surefire. For this, run
mvn -X test and look for a line that mentions surefire. It should look like this:
maven-surefire-plugin: resolved to version 2.3 from repository central. If you use pre-Surefire-2.4 start using
Fortunately beyond 2020 older version usage shrinks and you should remember to always favor a
Surefire itself is the intermediate plugin between Maven and JUnit/TestNG for which while
-DskipTests works and
-Dmaven.test.skip=true works for compiler.
You can find (not really much more) additional info about shortening the build time trough skipping the project tests at maven skipping tests site.
You can add this plugin configuration to your pom if you do not want to set command line arguments:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <skipTests>true</skipTests> </configuration> </plugin>
Or you can also set skipping tests in you POM file over property:
<properties> <maven.test.skip>true</maven.test.skip> </properties>
Bonus You can also skip tests in IntelliJ Idea. Just go to Maven tool tab and hit ‘Skip Test’ mode.