Maven Practical Tips 03. How to ignore test cases when Maven compiles packaging

Source: Internet
Author: User

Skip the test phase:


MVN package-dskiptests


Temporarily skip the compilation of the test code:


MVN package-dmaven.test.skip=true


Maven.test.skip also controls the behavior of the Maven-compiler-plugin and maven-surefire-plugin two plug-ins, skipping compilation and skipping tests.


Specifying Test classes


MVN test-dtest=randomgeneratortest

The test class that starts with random and ends with test

MVN test-dtest=random*test

Specify multiple test cases separated by commas

MVN test-dtest=atest,btest


Specifies that even without any test cases, do not error


The test parameter must match at least one Test class, or it will error and cause the build to fail. You can use the following configuration to specify that you do not make any error even if you do not have any test cases.

MVN test-dtest-dfailifnotests = False


Pom file configuration contains and excludes test cases


Use * */* Test.java to match all Java classes ending with tests. Two asterisk * * to match any path, an asterisk * is used to get 0 or more characters except the path style character. You can also use excludes to exclude some test classes.

<plugin>
    <groupId>org.apahce.maven.plugins<groupId>
    <artifactId> maven-surefire-plugin</artifactid>
    <version>2.5</version>
    <configuration>
        <includes>
            <include>**/*Tests.java</include>
        </includes>
    </ Configuration>        
</plugin>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.