DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Integrate Cucumber in Playwright With Java
  • Test Automation: Maven Profiles and Parallelization in Azure Pipelines Using IaaS
  • DGS GraphQL and Spring Boot
  • Comprehensive Guide to Property-Based Testing in Go: Principles and Implementation

Trending

  • The Role of Retrieval Augmented Generation (RAG) in Development of AI-Infused Enterprise Applications
  • STRIDE: A Guide to Threat Modeling and Secure Implementation
  • Getting Started With GenAI on BigQuery: A Step-by-Step Guide
  • Virtual Threads: A Game-Changer for Concurrency
  1. DZone
  2. Coding
  3. Java
  4. Maven Skipping Tests

Maven Skipping Tests

In this quick article, we will look into different ways to skip tests in maven applications.

By 
Ramesh Fadatare user avatar
Ramesh Fadatare
·
Dec. 21, 18 · Code Snippet
Likes (7)
Comment
Save
Tweet
Share
38.6K Views

Join the DZone community and get the full member experience.

Join For Free

Sometimes, we need to disable JUnit test cases written in Maven projects. When we build a Maven package, by default, Maven will execute the JUnit test cases.

Skipping Tests

If you are using Maven-surefire-plugin in your pom.xml, then it's easy to skip running the tests for a particular project and set the skipTests property to true.

<project>
  [...]

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.12.4</version>
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>
        </plugins>
    </build>
  [...]

</project>


From the Command Line

You can also skip the tests via the command line by executing the following command:

mvn install -DskipTests


If you absolutely must, you can also use the maven.test.skip property to skip compiling the tests. maven.test.skip is honored by Surefire, Failsafe, and the Compiler Plugin.

mvn install -Dmaven.test.skip=true


Skipping by Default

If you want to skip tests by default, but also want the ability to re-enable tests from the command line, you need to go via a properties section in the pom:

<project>
  [...]

    <properties>
        <skipTests>true</skipTests>
    </properties>
  [...]

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.12.4</version>
                <configuration>
                    <skipTests>${skipTests}</skipTests>
                </configuration>
            </plugin>
        </plugins>
    </build>
  [...]

</project>


This will allow you to run with tests disabled by default and to run them with this command:

mvn install -DskipTests=false


The same can be done with the "skip" parameter and other booleans on the plugin.

You can learn maven in-depth here. Happy coding !!

Testing Apache Maven

Published at DZone with permission of Ramesh Fadatare. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Integrate Cucumber in Playwright With Java
  • Test Automation: Maven Profiles and Parallelization in Azure Pipelines Using IaaS
  • DGS GraphQL and Spring Boot
  • Comprehensive Guide to Property-Based Testing in Go: Principles and Implementation

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: