Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to ignore test cases when Maven compiles and packages

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article is about how to ignore test cases when Maven is compiled and packaged. I think it is very practical, so I share it with you. I hope you can get something after reading this article.

Skip the testing phase

Mvn package-DskipTests

Temporarily skip the compilation of test code

Mvn package-Dmaven.test.skip=true

Maven.test.skip controls the behavior of both maven-compiler-plugin and maven-surefire-plugin plug-ins, skipping compilation and testing.

Specify test class

Test classes that begin with Random and end with Test

Mvn test-Dtest=RandomGeneratorTest

Mvn test-Dtest=Random*Test

Specify multiple test cases separated by commas

Mvn test-Dtest=ATest,BTest

Specify not to report an error even if there are no test cases

The test parameter must match at least one test class, otherwise an error will be reported and the build will fail. At this point, you can use the following configuration to specify that errors are not reported even if there are no test cases.

Mvn test-Dtest-DfailIfNoTests = false

POM file configuration includes and excludes test cases

Use * * / * Test.java to match all Java classes that end in Tests. Two asterisks * * are used to match any path, and one asterisk * is used to obtain 0 or more characters except path style characters. You can also use excludes to exclude some test classes.

Org.apahce.maven.plugins maven-surefire-plugin 2.5 * * / * Tests.java

The above is how to ignore test cases when Maven is compiled and packaged, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report