michael nesterenko
michael nesterenko

Reputation: 14449

maven skip tests with compilation errors

Are there an option to skip tests with compilation errors? Just ignore them or treat them as failed?

Upvotes: 7

Views: 9796

Answers (5)

Rashid
Rashid

Reputation: 375

The best way to use command line mvn install -Dmaven.test.skip=true.

Reference: Maven skipping test

Upvotes: 0

Ozyman
Ozyman

Reputation: 513

-DskipTests usually works. For instance, mvn install -DskipTests.

If you need to tell maven strictly to ignore - use -Dmaven.test.skip=true. This will force all the plugins and compiler to ignore the tests

Edited: Looks like -DskipTests=true also works!

Upvotes: 0

user1665207
user1665207

Reputation: 79

use the following command to skip the entire test source folder. Through there are compilation errors in the test classes maven wont consider those, if you use the following command.

mvn clean install -Dmaven.test.skip=true

Upvotes: 2

orien
orien

Reputation: 2210

The maven-compiler-plugin is responsible for compiling your tests during the test-compile phase. This plugin is configured to fail the build if any test classes fail to compile. You could experiment with the failOnError configuration. But I doubt you'll get the results you expect. The compilation process stops immediately when it encounters a compilation error. So potentially issue free classes may not have been re-compiled. Therefore there will be no guarantee the .class files you execute during the test phase will be 'up to date' with the corresponding .java source files.

  <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <executions>
      <execution>
        <id>default-testCompile</id>
        <phase>test-compile</phase>
        <goals>
          <goal>testCompile</goal>
        </goals>
        <configuration>
          <failOnError>false</failOnError>
        </configuration>
      </execution>
    </executions>
  </plugin>

Upvotes: 9

Jaco Van Niekerk
Jaco Van Niekerk

Reputation: 4192

Not recommended...

mvn -DskipTests=true clean compile

Remember, with great power comes great responsibility.

Upvotes: 1

Related Questions