How to skip Maven unit test

By default, when building project, Maven will run the entire unit tests automatically. If any of unit test is failed, it will force Maven to abort the building process.

$ mvn install
$ mvn package

In real life, you may “STILL” need to build your project even some of the cases are failed.

Skip Unit Test

To skip the entire unit test, uses argument “-Dmaven.test.skip=true“.

$ mvn install -Dmaven.test.skip=true
$ mvn package -Dmaven.test.skip=true

Or define skipTests in maven-surefire-plugin.


Now, build the project again, the entire unit tests will be ignored.

Tags :

About the Author

Founder of and, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider make a donation to these charities.


  • Pingback: alkaline water brands()

  • Pingback: paypal loans()

  • Pingback: Instagram followers kopen()

  • Pingback: laan penge nu uden renter()

  • Pingback: alkaline water benefits()

  • Pingback: alkaline water()

  • Pingback: stop parking()

  • Pingback: laan penge()

  • Pingback: parking()

  • Pingback: fue()

  • Pingback: lan penge nu()

  • Pingback: get satellite tv()

  • Pingback: Home made couples()

  • Pingback: Housewife amateurs deep-throating at cfnm()

  • Pingback: online casinos()

  • Pingback: tv online, online tv()

  • Pingback: stream movies()

  • Pingback: Blue Coaster33()

  • Sean

    Hi mkyong

    Your posts are really helpful! Thanks!

  • Sean

    Hi Mkyong

    Your posts are great! really helpful!

  • Aleksandar Bosancic

    Hello MK, I think it’s better solution for skip test use the properties



    • Aleksandar Bosancic

      Sorry, ‘pre’ does not work so good :), here is config


  • Laurent C.

    I can argue about this commandline but this blog made it better:

    Source: Learning by Experience

    Recently came across this the existance of the -DskipTests argument while running maven.

    From the userguide:

    You can also skip the tests via 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

    Skiptests is a feature of surefire, while -Dmaven.test.skip is a feature of maven itself.

  • alka

    Waw! thx A lot master! your tip make my day more easy.

  • Scott


    using true in the pom causes Maven to skip test execution. Is there any way to tell Maven to not compile the tests as well using a element in the pom instead of command line? Something such as true


    • Scott

      Sorry, did not use the source code comment:


  • Pete

    Well, the test was one we could safely ignore:
    testFindDomainBounds in the TimeSeriesCollectionTests returned:
    expected: but was:
    So we can assume it’s a basic rounding error, but very minor so safe to ignore.
    Not sure if it’s a Mac thing, perhaps a 64-bit issue but the test should be updated to round somewhat.

  • Pete

    Thanks alot mkyong. I had one unit test out of over 2000 fail in jFreeChart! Annoying, but your tip saved the day. Thanks again…
    Melbourne, Australia

    • mkyong

      haha, you need to find out why the tests are failed, skip is just ignore it temporary :)

  • Pingback: How to skip Maven unit test | Just another software blog()

  • Pingback: Maven Tutorials | Tutorials()