13

Using Maven build configuration, we can configure it to skip test execution while building the source file. In eclipse we can check the checkbox labeled as 'Skip Test` and from command line we can use

mvn clean install -Dmaven.test.skip=true

The Skip test doesn't even compile the unit test source codes.

Is there any way to configure maven such that it will compile the unit test classes but doesn't execute it?

Mureinik
  • 297,002
  • 52
  • 306
  • 350
sakura
  • 2,249
  • 2
  • 26
  • 39
  • I agree with answers below, In case someone wanted to know more detail or how to skip failed tests: https://stackoverflow.com/questions/3365553/how-to-build-a-jar-using-maven-ignoring-test-results – whoami - fakeFaceTrueSoul Jul 31 '18 at 15:41

4 Answers4

21

It compiles test classes when you specify -DskipTests it just skips execution of tests

maven.test.skip stops compilation of test classes


Documentation

jmj
  • 237,923
  • 42
  • 401
  • 438
7

-Dmaven.test.skip=true is designed not to even compile the unit tests. If you want to build them but not run them, you could use the skipTests flag:

mvn clean install -DskipTests=true

or in its shorthand version:

mvn clean install -DskipTests

See also maven's documentation on skipping tests for the full details.

Mureinik
  • 297,002
  • 52
  • 306
  • 350
0
<properties>
    <maven.test.skip>true</maven.test.skip>
</properties>

Add this code in your pom.xml file.

Amit
  • 1,540
  • 1
  • 15
  • 28
-1

When runnig a mvn install, you can either:

  • Skip tests excution and compilation: -Dmaven.test.skip=true
  • Skip only tests execution but compile them: -DskipTests=true

Note that those properties defaults to false when not explicitelly specified.

tmarwen
  • 15,750
  • 5
  • 43
  • 62