sakura
sakura

Reputation: 2279

Skip test case execution in maven doesn't even compile Test cases

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?

Upvotes: 13

Views: 26524

Answers (4)

Amit
Amit

Reputation: 1560

<properties>
    <maven.test.skip>true</maven.test.skip>
</properties>

Add this code in your pom.xml file.

Upvotes: 0

tmarwen
tmarwen

Reputation: 16384

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.

Upvotes: -1

Mureinik
Mureinik

Reputation: 312267

-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.

Upvotes: 7

Jigar Joshi
Jigar Joshi

Reputation: 240996

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

maven.test.skip stops compilation of test classes


Documentation

Upvotes: 21

Related Questions