Maven skip tests

0 votes

I have been using Maven 2.2.1 and to build my project I used this command

mvn clean install -Dmaven.test.skip=true


However, the build failed saying it couldn't find one of the artifacts. However, when I used:

mvn clean install -DskipTests


Everything worked fine and since then, I have been thinking that these 2 commands are equivalent. However, the link seems to suggest that -Dmaven.test.skip=true also skips compiling the test cases. However, that still didn't explain to me why one command is working and another is not. It will be great if anyone please explain this to me.

Feb 10, 2022 in Others by Soham
• 9,710 points
2,022 views

1 answer to this question.

0 votes

You have correctly pointed out that the -Dmaven.test.skip=true will skip compiling the tests. This will also skip building the test artifacts like you mentioned. However, a common practice for large projects is to have testing utilities and various base classes shared among modules in the same project. The code below is accomplished by having a module require a test-jar of a previously built module:
 

<dependency> 
    <groupId>org.myproject.mygroup</groupId>
  <artifactId>common</artifactId> 
  <version>1.0</version> 
  <type>test-jar</type>
  <scope>test</scope> 
</dependency>

If the -Dmaven.test.skip=true has been elaborately stated, then test-jars aren't built, and any module that relies on them will fail to build obviously. Following that, once you use -DskipTests, Maven does not run the tests, but it does compile them and build the test-jar, making it available for the subsequent modules.

answered Feb 10, 2022 by Rahul
• 9,680 points

Related Questions In Others

0 votes
1 answer
0 votes
1 answer

Maven in Eclipse: step by step installation

There are steps noted in order to ...READ MORE

answered Feb 18, 2022 in Others by Aditya
• 7,680 points
1,794 views
0 votes
1 answer

In excel 365 how to subtract values sequentially but skip empty cells

Try the following formula in C4 and ...READ MORE

answered Dec 24, 2022 in Others by narikkadan
• 63,680 points
764 views
0 votes
1 answer

Conditions in Excel: skip cells with dates without a year

Both Google Sheets and Excel save dates ...READ MORE

answered Jan 17, 2023 in Others by narikkadan
• 63,680 points
390 views
0 votes
1 answer

How to add if this cell = 0 skip and go next

Try this: Option Explicit Sub AutoMakeInv() ...READ MORE

answered Jan 20, 2023 in Others by narikkadan
• 63,680 points
361 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
3,985 views
+2 votes
1 answer
0 votes
1 answer

How to skip tests in PHPunit?

Hello, The fastest and easiest way to skip ...READ MORE

answered Nov 10, 2020 in PHP by Niroj
• 82,880 points
5,579 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP