Bug 364552 - "mvn install -DskipTests" does not skip the tests
Summary: "mvn install -DskipTests" does not skip the tests
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Tycho (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Jan Sievers CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 364856 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-11-23 04:37 EST by Geoffrey De Smet CLA
Modified: 2021-04-28 16:54 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Geoffrey De Smet CLA 2011-11-23 04:37:37 EST
Build Identifier: 0.13.0

I upgraded to tycho 0.13.0 and ran:
  mvn clean install -DskipTests
yet tests where run:
  Tests run: 257, Failures: 0, Errors: 0, Skipped: 134


I've reported this issue before, but the issue is lost in bugzilla.

Reproducible: Always

Steps to Reproduce:
mvn clean install -DskipTests
Comment 1 Jan Sievers CLA 2011-11-23 04:39:43 EST
use -Dmaven.test.skip=true
Comment 2 Geoffrey De Smet CLA 2011-11-23 04:45:35 EST
maven.test.skip=true does not check the tests for compilation errors, skipTests does that.
Furthermore, in a multiproject, a tycho subproject should be a good citizen and support "skipTests" (and "maven.test.skip") in the same way of all the other subprojects.
Comment 3 Jan Sievers CLA 2011-11-23 05:30:24 EST
(In reply to comment #2)
> maven.test.skip=true does not check the tests for compilation errors, skipTests
> does that.

There are some differences between maven surefire and tycho-surefire.
One of them is that for tycho-surefire, tests are always in a separate project.
This is fundamentally because Tycho is MANIFEST-first and MANIFEST dependencies do not have a "test" scope as maven has for POM dependencies.
For tycho, maven.test.skip=true skips test execution, not test compilation.

> Furthermore, in a multiproject, a tycho subproject should be a good citizen and
> support "skipTests" (and "maven.test.skip") in the same way of all the other
> subprojects.

You mean you are mixing pom-first and manifest-first in the same reactor?
This is not supported, see [1].

That said, if you still see an issue here, attach a sample project with steps to reproduce, expected behaviour and observed behaviour so we can see what you are talking about.

[1] https://docs.sonatype.org/display/TYCHO/Dependency+on+pom-first+artifacts
Comment 4 Geoffrey De Smet CLA 2011-11-23 05:45:09 EST
The difference between surefire and tycho-surefire being what they are (and justified), not supporting -DskipTests violates the principle of least surprise. 

I see no reason not to support it? It would make our builds faster if we can compile without running the tests on the tycho projects too.

To reproduce:

git clone git@github.com:droolsjbpm/droolsjbpm-build-bootstrap.git
git clone git@github.com:droolsjbpm/drools-planner.git
git clone git@github.com:droolsjbpm/droolsjbpm-tools.git
# droolsjbpm-tools is the tycho based multiproject
droolsjbpm-build-bootstrap/script/mvn-all.sh clean install -DskipTests

Notice how we build everything with a single mvn command. It's non-intuitive to be forced to use a different mvn command on tycho based projects than on the other projects.
Comment 5 Jan Sievers CLA 2011-11-23 06:34:15 EST
(In reply to comment #4)
> The difference between surefire and tycho-surefire being what they are (and
> justified), not supporting -DskipTests violates the principle of least
> surprise. 
> 
> I see no reason not to support it? It would make our builds faster if we can
> compile without running the tests on the tycho projects too.
> 
> To reproduce:
> 
> git clone git@github.com:droolsjbpm/droolsjbpm-build-bootstrap.git
> git clone git@github.com:droolsjbpm/drools-planner.git
> git clone git@github.com:droolsjbpm/droolsjbpm-tools.git
> # droolsjbpm-tools is the tycho based multiproject
> droolsjbpm-build-bootstrap/script/mvn-all.sh clean install -DskipTests
> 
> Notice how we build everything with a single mvn command. It's non-intuitive to
> be forced to use a different mvn command on tycho based projects than on the
> other projects.

tycho does support the (albeit deprecated) -Dmaven.test.skip.exec [1] which has the same effect as -DskipTests so this should work around your issue in the meantime.

The root cause why we violate "least surprise" here is that we cannot subclass the original surefire mojo (or any other mojo for that matter) due to maven core issue [2] .

Instead we have a separate mojo that should behave *similar* but it's tedious to keep it up to date with the original surefire mojo. Also, there are certain features of the maven surefire plugin which we will probably never be able to support.

[1] http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html#skipExec
[2] http://jira.codehaus.org/browse/MPLUGIN-56
Comment 6 Geoffrey De Smet CLA 2011-11-23 07:12:08 EST
> Instead we have a separate mojo that should behave *similar*
+1 for similar behavior by hooking -DskipTests to -Dmaven.test.skip.exec
Comment 7 Igor Fedorenko CLA 2011-11-23 07:17:20 EST
Updating parameters one by one is too much effort for Tycho developers and we'd rather spend our limited resources on more serious problems. The real solution here is to refactore surefire such that it can be extended for Tycho needs, so if somebody contributes a patch, I will help to review and merge it.
Comment 8 Jan Sievers CLA 2011-11-25 12:29:28 EST
*** Bug 364856 has been marked as a duplicate of this bug. ***