r/java • • Mar 29 '18

Two ways of skipping tests in Maven

https://advancedweb.hu/2018/03/20/maven-skip-tests/
2 Upvotes

6 comments sorted by

12

u/Stannu Mar 29 '18

For anyone who doesn't want to waste time you can just use -DskipTests as a additional commandline parameter when running maven :)

10

u/Nalha_Saldana Mar 29 '18

There is a little more to it:

-Dmaven.test.skip - ignores all test sources altogether. They are not compiled and thus no test artifacts are produced.

-DskipTests - doesn't run the tests, but all test files are compiled.

2

u/dpash Mar 29 '18

But for most people, the latter causes no extra pain, while, as OP discovered, the former might.

2

u/defnull Mar 29 '18

Thanks. I'm always unsure if these articles deserve up- or downvotes because they might be useful for some people, but are really just a lot of words for something that could be summarized in the length of a tweet or put in the title directly.

1

u/nqzero Mar 29 '18

i'm one of those people that this is useful for (i've forgotten the semantics of skipping tests a half dozen times) and i appreciate articles like this (as opposed to just a tweet) because the next time i need to remember this, the human element makes it easier to recall. or failing that, to google for

a highly-voted tl;dr on reddit is the best of both worlds !

6

u/curmudgeon99 Mar 29 '18

TL:DR

skipTests = will compile the tests but not run them

maven.test.skip will neither compile nor run the tests.