Maven - How to compile tests without running them?

Is there a way in Maven to compile tests without running them? I want to use the IDE to run certain tests, not for everyone.

+80
maven
Jan 22 2018-11-11T00:
source share
7 answers

you can try using the -DskipTests parameter

Literature:

+28
Jan 22 '11 at 3:26 a.m.
source share

What about the test-compile life cycle phase? This does not require skipping the test because it occurs before the test phase. I.e.

 $ mvn test-compile 

And done.

An introduction to the assembly life cycle is explained below.

+209
Jan 25 '11 at 16:21
source share

When fulfilling a goal that will include a testing phase (for example, a package), you can do two things:

  • Use the mvn -DskipTests=true package command. This will compile everything but not run them.
  • Or mvn -Dmaven.test.skip=true package . This will not compile or run the test branch.
+21
May 19 '13 at 9:25
source share

To simply compile tests and code without running them, simply do:

 mvn test-compile compile 
+8
Dec 30 '15 at 10:41
source share

If the settings.xml file you can also use

 <maven.test.skip>true</maven.test.skip> 
+1
Jan 25 2018-11-18T00:
source share

The Maven Surefire Plugin documentation is clear:

skipTests
Set this to true to skip the current tests, but still compile them. (...)
The default value is false.
User Property: skipTests.

This option is available because in Maven Surefire Plugin 2.4+

+1
Feb 26 '15 at 10:42
source share

If you really only want to compile the tests (skip all other phases, for example compile ), this will be

 mvn org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile 

See the default lifecycle plugin bindings .

0
Nov 29 '14 at 19:48
source share



All Articles