ach00
ach00

Reputation: 45

How to modify POM.xml to enable unit tests only on "mvn test"

I have a Java maven project. I am successfully able to disable the execution of unit tests through

<properties>
    <java.version>1.8</java.version>
    <maven.test.skip>false</maven.test.skip>
</properties>

However, this also disables unit tests when I run the "mvn test" command

Is it possible to modify POM.xml to have unit tests execute only through the command "mvn test", and disable unit tests when "mvn clean" or other such commands are run?

Upvotes: 0

Views: 863

Answers (1)

J Fabian Meier
J Fabian Meier

Reputation: 35805

No.

This is also not how it is meant to be used.

Maven has a lifecycle. When you run mvn install or mvn deploy, this always includes the test phase. You can, of course, use command line parameters to skip the tests in one case and not the other.

Upvotes: 1

Related Questions