[SUREFIRE-1153] Take includes into account when using test/it.test property
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/1edb3c12 Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/1edb3c12 Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/1edb3c12 Branch: refs/heads/master Commit: 1edb3c12653dba5705edbc6529534e9a2ec22f15 Parents: 7ffd542 Author: Tibor17 <tibo...@lycos.com> Authored: Wed May 20 00:41:36 2015 +0200 Committer: Tibor17 <tibo...@lycos.com> Committed: Thu May 28 22:47:00 2015 +0200 ---------------------------------------------------------------------- .../plugin/surefire/AbstractSurefireMojo.java | 41 ++++++-------------- .../Surefire1153IncludesAndSpecifiedTestIT.java | 10 ++++- .../Surefire806SpecifiedTestControlsIT.java | 3 ++ .../pom.xml | 16 +++++--- 4 files changed, 32 insertions(+), 38 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/1edb3c12/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java ---------------------------------------------------------------------- diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java index 6287969..6a8a309 100644 --- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java +++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java @@ -25,7 +25,6 @@ import java.io.IOException; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; @@ -54,8 +53,6 @@ import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.execution.MavenSession; -import org.apache.maven.model.Plugin; -import org.apache.maven.model.PluginExecution; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -1634,39 +1631,39 @@ public abstract class AbstractSurefireMojo private List<String> getIncludeList() throws MojoFailureException { - List<String> actualIncludes = null; - if ( isSpecificTestSpecified() && !isMultipleExecutionBlocksDetected() ) + List<String> includes = null; + if ( isSpecificTestSpecified() ) { - actualIncludes = Collections.singletonList( "**/*" ); + includes = Collections.singletonList( getTest() ); } else { if ( getIncludesFile() != null ) { - actualIncludes = readListFromFile( getIncludesFile() ); + includes = readListFromFile( getIncludesFile() ); } // If we have includesFile, and we have includes, then append includes to includesFile content - if ( actualIncludes == null ) + if ( includes == null ) { - actualIncludes = getIncludes(); + includes = getIncludes(); } else { - maybeAppendList( actualIncludes, getIncludes() ); + maybeAppendList( includes, getIncludes() ); } - checkMethodFilterInIncludesExcludes( actualIncludes ); + checkMethodFilterInIncludesExcludes( includes ); // defaults here, qdox doesn't like the end javadoc value // Have to wrap in an ArrayList as surefire expects an ArrayList instead of a List for some reason - if ( actualIncludes == null || actualIncludes.isEmpty() ) + if ( includes == null || includes.isEmpty() ) { - actualIncludes = Arrays.asList( getDefaultIncludes() ); + includes = Arrays.asList( getDefaultIncludes() ); } } - return filterNulls( actualIncludes ); + return filterNulls( includes ); } private void checkMethodFilterInIncludesExcludes( Iterable<String> patterns ) @@ -1720,22 +1717,6 @@ public abstract class AbstractSurefireMojo return result; } - private boolean isMultipleExecutionBlocksDetected() - { - MavenProject project = getProject(); - if ( project != null ) - { - String key = getPluginDescriptor().getPluginLookupKey(); - Plugin plugin = (Plugin) project.getBuild().getPluginsAsMap().get( key ); - if ( plugin != null ) - { - Collection<PluginExecution> executions = plugin.getExecutions(); - return executions != null && executions.size() > 1; - } - } - return false; - } - private Artifact getTestNgArtifact() throws MojoExecutionException { http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/1edb3c12/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1153IncludesAndSpecifiedTestIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1153IncludesAndSpecifiedTestIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1153IncludesAndSpecifiedTestIT.java index 6f42458..3a2c826 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1153IncludesAndSpecifiedTestIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1153IncludesAndSpecifiedTestIT.java @@ -29,12 +29,18 @@ public class Surefire1153IncludesAndSpecifiedTestIT @Test public void testSpecifiedTestInIncludes() { - unpack( "/surefire-1153-includesAndSpecifiedTest" ).setTestToRun( "#testIncluded" ).executeTest().verifyErrorFree( 1 ); + unpack( "/surefire-1153-includesAndSpecifiedTest" ) + .setTestToRun( "#testIncluded" ) + .executeTest() + .verifyErrorFree( 1 ); } @Test public void testSpecifiedTestNotInIncludes() { - unpack( "/surefire-1153-includesAndSpecifiedTest" ).setTestToRun( "#testNotIncluded" ).executeTest().verifyErrorFree( 1 ); + unpack( "/surefire-1153-includesAndSpecifiedTest" ) + .setTestToRun( "#testNotIncluded" ) + .executeTest() + .verifyErrorFree( 1 ); } } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/1edb3c12/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire806SpecifiedTestControlsIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire806SpecifiedTestControlsIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire806SpecifiedTestControlsIT.java index d6a96c0..70e4d63 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire806SpecifiedTestControlsIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire806SpecifiedTestControlsIT.java @@ -21,6 +21,7 @@ package org.apache.maven.surefire.its.jiras; import org.apache.maven.surefire.its.Not2xCompatible; import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.junit.Ignore; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -30,6 +31,7 @@ public class Surefire806SpecifiedTestControlsIT { @Test + @Ignore( "since SUREFIRE-1153 the includes/excludes are overridden by -Dtest or it.test for whatever execution" ) public void singleTestInOneExecutionOfMultiExecutionProject() { unpack( "/surefire-806-specifiedTests-multi" ).setTestToRun( "FirstTest" ).failIfNoSpecifiedTests( @@ -37,6 +39,7 @@ public class Surefire806SpecifiedTestControlsIT } @Test + @Ignore( "since SUREFIRE-1153 the includes/excludes are overridden by -Dtest or it.test for whatever execution" ) public void twoSpecifiedTestExecutionsInCorrectExecutionBlocks() { unpack( "/surefire-806-specifiedTests-multi" ).setTestToRun( http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/1edb3c12/surefire-integration-tests/src/test/resources/surefire-1153-includesAndSpecifiedTest/pom.xml ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/resources/surefire-1153-includesAndSpecifiedTest/pom.xml b/surefire-integration-tests/src/test/resources/surefire-1153-includesAndSpecifiedTest/pom.xml index 0f88caa..b8b4a03 100644 --- a/surefire-integration-tests/src/test/resources/surefire-1153-includesAndSpecifiedTest/pom.xml +++ b/surefire-integration-tests/src/test/resources/surefire-1153-includesAndSpecifiedTest/pom.xml @@ -17,27 +17,24 @@ ~ specific language governing permissions and limitations ~ under the License. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.maven.surefire</groupId> <artifactId>it-parent</artifactId> <version>1.0</version> - <relativePath>../pom.xml</relativePath> </parent> <groupId>org.apache.maven.plugins.surefire</groupId> <artifactId>jiras-surefire-1153</artifactId> <version>1.0</version> <url>http://maven.apache.org</url> - <properties> - <version.junit>4.12</version.junit> - </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> - <version>${version.junit}</version> + <version>4.12</version> <scope>test</scope> </dependency> </dependencies> @@ -57,6 +54,13 @@ <include>**/*UT.java</include> </includes> </configuration> + <executions> + <execution> + <goals> + <goal>test</goal> + </goals> + </execution> + </executions> </plugin> </plugins> </build>