This is an automated email from the ASF dual-hosted git repository. tibordigana pushed a commit to branch SUREFIRE-1787 in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
The following commit(s) were added to refs/heads/SUREFIRE-1787 by this push: new ba67f4f integration test ba67f4f is described below commit ba67f4f7f0af1767e328314c17389e67cf732398 Author: tibordigana <tibordig...@apache.org> AuthorDate: Sun May 10 19:18:37 2020 +0200 integration test --- .../plugin/surefire/AbstractSurefireMojo.java | 21 +++--- .../surefire/its/jiras/Surefire1787JUnit5IT.java | 82 ++++++++++++++++++++++ surefire-its/src/test/resources/junit-4-5/pom.xml | 9 +-- 3 files changed, 98 insertions(+), 14 deletions(-) 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 b9258fc..9fa9d88 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 @@ -3136,34 +3136,35 @@ public abstract class AbstractSurefireMojo String surefireVersion = getBooterArtifact().getBaseVersion(); Map<String, Artifact> providerArtifacts = surefireDependencyResolver.getProviderClasspathAsMap( "surefire-junit-platform", surefireVersion ); - Map<String, Artifact> testDependencies = testClasspath.getTestDependencies(); + Map<String, Artifact> testDeps = testClasspath.getTestDependencies(); ProjectBuildingRequest request = getSession().getProjectBuildingRequest(); Plugin plugin = getPluginDescriptor().getPlugin(); - Map<String, Artifact> engines = + Map<String, Artifact> pluginDeps = surefireDependencyResolver.resolvePluginDependencies( request, plugin, getPluginArtifactMap() ); - if ( hasDependencyPlatformEngine( engines ) ) + if ( hasDependencyPlatformEngine( pluginDeps ) ) { - providerArtifacts.putAll( engines ); + providerArtifacts.putAll( pluginDeps ); } - else if ( !hasDependencyPlatformEngine( testDependencies ) ) + else { String engineVersion = null; - if ( hasDependencyJupiterAPI( testDependencies ) ) + if ( hasDependencyJupiterAPI( testDeps ) + && !testDeps.containsKey( "org.junit.jupiter:junit-jupiter-engine" ) ) { String engineGroupId = "org.junit.jupiter"; String engineArtifactId = "junit-jupiter-engine"; String engineCoordinates = engineGroupId + ":" + engineArtifactId; String api = "org.junit.jupiter:junit-jupiter-api"; - engineVersion = testDependencies.get( api ).getBaseVersion(); + engineVersion = testDeps.get( api ).getBaseVersion(); getConsoleLogger().debug( "Test dependencies contain " + api + ". Resolving " + engineCoordinates + ":" + engineVersion ); addEngineByApi( engineGroupId, engineArtifactId, engineVersion, providerArtifacts ); } - if ( testDependencies.containsKey( "junit:junit" ) - || testDependencies.containsKey( "junit:junit-dep" ) ) + if ( ( testDeps.containsKey( "junit:junit" ) || testDeps.containsKey( "junit:junit-dep" ) ) + && !testDeps.containsKey( "org.junit.vintage:junit-vintage-engine" ) ) { String engineGroupId = "org.junit.vintage"; String engineArtifactId = "junit-vintage-engine"; @@ -3178,7 +3179,7 @@ public abstract class AbstractSurefireMojo } } - narrowDependencies( providerArtifacts, testDependencies ); + narrowDependencies( providerArtifacts, testDeps ); alignProviderVersions( providerArtifacts ); return new LinkedHashSet<>( providerArtifacts.values() ); diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1787JUnit5IT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1787JUnit5IT.java new file mode 100644 index 0000000..0423993 --- /dev/null +++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1787JUnit5IT.java @@ -0,0 +1,82 @@ +package org.apache.maven.surefire.its.jiras; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase; +import org.junit.Test; + +/** + * + */ +public class Surefire1787JUnit5IT extends SurefireJUnit4IntegrationTestCase +{ + @Test + public void bothEngines() + { + unpack( "junit-4-5" ) + .activateProfile( "both-engines" ) + .executeTest() + .verifyErrorFree( 2 ) + .verifyTextInLog( "Running pkg.JUnit4Test" ) + .verifyTextInLog( "Running pkg.JUnit5Test" ); + } + + @Test + public void apiAndEngine() + { + unpack( "junit-4-5" ) + .activateProfile( "api-and-engines" ) + .executeTest() + .verifyErrorFree( 2 ) + .verifyTextInLog( "Running pkg.JUnit4Test" ) + .verifyTextInLog( "Running pkg.JUnit5Test" ); + } + + @Test + public void bothApis() + { + unpack( "junit-4-5" ) + .activateProfile( "both-api" ) + .executeTest() + .verifyErrorFree( 2 ) + .verifyTextInLog( "Running pkg.JUnit4Test" ) + .verifyTextInLog( "Running pkg.JUnit5Test" ); + } + + @Test + public void selectJUnit4() + { + unpack( "junit-4-5" ) + .activateProfile( "select-junit4" ) + .executeTest() + .verifyErrorFree( 1 ) + .verifyTextInLog( "Running pkg.JUnit4Test" ); + } + + @Test + public void selectJUnit5() + { + unpack( "junit-4-5" ) + .activateProfile( "select-junit5" ) + .executeTest() + .verifyErrorFree( 1 ) + .verifyTextInLog( "Running pkg.JUnit5Test" ); + } +} diff --git a/surefire-its/src/test/resources/junit-4-5/pom.xml b/surefire-its/src/test/resources/junit-4-5/pom.xml index 7173eb1..546b8fc 100644 --- a/surefire-its/src/test/resources/junit-4-5/pom.xml +++ b/surefire-its/src/test/resources/junit-4-5/pom.xml @@ -9,8 +9,9 @@ <version>1.0-SNAPSHOT</version> <properties> - <maven.compiler.testSource>1.8</maven.compiler.testSource> - <maven.compiler.testTarget>1.8</maven.compiler.testTarget> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <maven.compiler.source>${java.specification.version}</maven.compiler.source> + <maven.compiler.target>${java.specification.version}</maven.compiler.target> </properties> <build> @@ -19,7 +20,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>3.0.0-SNAPSHOT</version> + <version>${surefire.version}</version> </plugin> </plugins> </pluginManagement> @@ -143,4 +144,4 @@ </profile> </profiles> -</project> \ No newline at end of file +</project>