Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
249 views
in Technique[技术] by (71.8m points)

java - Maven -DskipTests ignored

I'm building a Maven project with following SureFire configuration:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>${version.maven-surefire-plugin}</version>
    <configuration>
        <includes>
            <include>**/*Test.java</include>
        </includes>
    </configuration>
</plugin>

Problem is, that when I build it with mvn clean install -DskipTests=true, the tests are still being executed. What could be the problem?

I tried both -DskipTests(which is from the Maven website) and -DskipTests=true, which is added by IntelliJ Idea when I check "skip tests" checkbox.

I don't use any Maven settings.xml.

  • Maven version: 2.2.1
  • Surefire plugin: 2.3

EDIT If I comment out the SureFire plugin configuration, the parameter behaves as I expect to. What could be the problem with the configuration above?

question from:https://stackoverflow.com/questions/19838734/maven-dskiptests-ignored

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

What you did should work. How to debug this further:

  1. Run mvn help:effective-pom to see the whole POM that Maven will execute. Search it for test (case insensitive) to see if there is something odd.

  2. Run mvn test -X to get debug output. This will print the options used to configure the maven-surefire-plugin. Make sure you redirect the output to a file!

    In the log, you will see

    [DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-surefire-plugin:2.15:test' with basic configurator -->
    

    and then, some lines below that:

    [DEBUG]   (s) runOrder = filesystem
    [DEBUG]   (s) skip = false
    [DEBUG]   (s) skipTests = false
    

    These values mean that tests aren't skipped.

  3. Are you using a recent version of the plugin? Check here. Maybe this option wasn't supported for your version.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...