The long way through Software Craftsmanship

Tip: Differences in maven test execution

Oct 5, 2015 - 1 minute read - Comments - protiptipmaventestskip-testsmaven-test-skip

There are times when you only want to have the production code:

  • downstream job after a successful build
  • compiling in local after checkout from DVCS
  • spiking (possibly the tests are broken)
  • speeding up the process

For that, maven allows to skip the tests, selectively:

  • -DskipTests compiles the tests, but skips running them
  • -Dmaven.test.skip skips compiling the tests and does not run them. This can also be written as -Dmaven.test.skip=true

In case some of your tests depend on tests from another artifact (e.g. Object Mother, test infrastructure) and the latter has changed, you must compile the tests. You need to not execute the tests

For more information:

Disclaimer about AI/GenAI

As of 2026-05-06, the text in these articles and blog entries has been written without AI/GenAI, except I sometimes use a spellchecker to fix errors. Think Word's spellchecker, not ChatGPT.

Notes, as of today (2026-05-06):

  • No code snippet has been automatically generated, nor vibe-coded, nor generated and reviewed.
  • I don’t have any article with AI contribution.

For future entries:

  • I may have used GenAI for the code in the repo. The code I exemplify/copy in the article will always be reviewed and tested, not vibe-coded. I will specify it in each snippet or at the top/bottom of the article.
  • I normally don't use it for the text contents, although if I have used it for the article text, it would be indicated as such.

Any entry before 2026-05-06 does not contain any AI/GenAI.

For more information, read the AI/GenAI Policy

Tip: Propagate the failure in bash Java Tips & Gotchas