Avoiding using maven.test.skip
You may manage an extremely small project that does not evolve a lot without unit tests. But, any large-scale project cannot exist without unit tests. Unit tests provide the first level of guarantee that you do not break any existing functionality with a newly introduced code change. In an ideal scenario, you should not commit any code to a source repository without building the complete project with unit tests.
Maven uses the surefire
plugin to run tests and as a malpractice developers are used to skip the execution of unit tests by setting the maven.test.skip
property to true
, as follows:
$ mvn clean install –Dmaven.test.skip=true
This can lead to serious repercussions in the later stage of the project, and you must ensure that all your developers do not skip tests while building.
Using the requireProperty
rule of the Maven enforcer
plugin, you can ban developers from using the maven.test.skip
property.
The following shows the enforcer
plugin configuration that...