Maven - How to compile tests without running them ?

前端 未结 7 1600
时光说笑
时光说笑 2021-01-30 06:16

Is there a way in Maven to compile the tests without running them ? I want to use the IDE to run specific tests and not all of them.

相关标签:
7条回答
  • 2021-01-30 06:24

    How about the test-compile lifecycle phase? It doesn't require any test skipping, because it occurs before the test phase. I.e.,

    $ mvn test-compile
    

    And done.

    Introduction to the Build Lifecycle explains further.

    0 讨论(0)
  • 2021-01-30 06:26

    In case you really want to only compile the tests (skip all other phases like compile), this will do

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

    See the plugin bindings of the default lifecycle.

    0 讨论(0)
  • 2021-01-30 06:27

    you can try to use parameter -DskipTests

    References:

    • Maven Surefire Plugin # skipTests
    0 讨论(0)
  • 2021-01-30 06:27

    Alternatively, you can use maven.test.skip.exec option.

    mvn -Dmaven.test.skip.exec=true
    

    Maven will compile the tests without running them. I use this option in all my projects regularly.

    0 讨论(0)
  • 2021-01-30 06:27

    If you settings.xml file you can also use

    <maven.test.skip>true</maven.test.skip>
    
    0 讨论(0)
  • 2021-01-30 06:37

    To just compile the tests and code, without running them, just do:

    mvn test-compile
    
    0 讨论(0)
提交回复
热议问题