You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by so...@apache.org on 2018/09/28 08:32:37 UTC
[maven-surefire] branch 1564 updated: Improve JUnit Platform ITs by
checking all relevant class-path entries
This is an automated email from the ASF dual-hosted git repository.
sor pushed a commit to branch 1564
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
The following commit(s) were added to refs/heads/1564 by this push:
new 2fd3768 Improve JUnit Platform ITs by checking all relevant class-path entries
2fd3768 is described below
commit 2fd37683a1f115f5c4ba7dcf11da923c01d67788
Author: Christian Stein <so...@gmail.com>
AuthorDate: Fri Sep 28 10:32:17 2018 +0200
Improve JUnit Platform ITs by checking all relevant class-path entries
---
.../apache/maven/surefire/its/JUnitPlatformIT.java | 124 ++++++++++++++++-----
.../test/resources/junit-platform-1.3.1/pom.xml | 60 ++++++++++
.../JUnitPlatform_1_3_1_Test.java | 37 ++++++
3 files changed, 195 insertions(+), 26 deletions(-)
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformIT.java
index fbe527d..0ca726c 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformIT.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformIT.java
@@ -19,12 +19,17 @@ package org.apache.maven.surefire.its;
* under the License.
*/
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.maven.it.VerificationException;
import org.apache.maven.surefire.its.fixture.OutputValidator;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.junit.Before;
import org.junit.Test;
import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.is;
public class JUnitPlatformIT
extends SurefireJUnit4IntegrationTestCase
@@ -60,42 +65,55 @@ public class JUnitPlatformIT
}
@Test
- public void testJUnitPlatform_1_0_0()
+ public void testJUnitPlatform_1_0_0() throws VerificationException
{
- OutputValidator validator = unpack( "/junit-platform-1.0.0" )
- .addGoal("-X")
- .executeTest()
- .verifyErrorFree( 1 );
+ Map<String, String> versions = new HashMap<String, String>();
+ versions.put("surefire", "2.22.1-SNAPSHOT"); // TODO Extract current from build!
+ versions.put("platform", "1.0.0");
+ versions.put("jupiter", "5.0.0");
+ versions.put("opentest", "1.0.0");
+ versions.put("apiguardian", "1.0.0");
+
+ unpackExecuteAndVerifyVersions(versions);
+ }
+
+ @Test
+ public void testJUnitPlatform_1_1_1() throws VerificationException
+ {
+ Map<String, String> versions = new HashMap<String, String>();
+ versions.put("surefire", "2.22.1-SNAPSHOT"); // TODO Extract current from build!
+ versions.put("platform", "1.1.1");
+ versions.put("jupiter", "5.1.1");
+ versions.put("opentest", "1.0.0");
+ versions.put("apiguardian", "1.0.0");
- validator.verifyTextInLog( "test(compact) classpath" )
- .verifyTextInLog( "apiguardian-api-1.0.0.jar" )
- .verifyTextInLog( "junit-jupiter-api-5.0.0.jar" )
- .verifyTextInLog( "junit-jupiter-engine-5.0.0.jar" )
- .verifyTextInLog( "junit-platform-commons-1.0.0.jar" )
- .verifyTextInLog( "junit-platform-engine-1.0.0.jar" )
- .verifyTextInLog( "opentest4j-1.0.0.jar" );
-
- validator.verifyTextInLog( "provider(compact) classpath" )
- .verifyTextInLog( "surefire-api-" ) // and current version, like "2.22.1-SNAPSHOT.jar"
- .verifyTextInLog( "surefire-junit-platform-" ) // and current version, like "2.22.1-SNAPSHOT.jar"
- .verifyTextInLog( "apiguardian-api-1.0.0.jar" )
- .verifyTextInLog( "junit-jupiter-engine-5.0.0.jar" )
- .verifyTextInLog( "junit-platform-commons-1.0.0.jar" )
- .verifyTextInLog( "junit-platform-engine-1.0.0.jar" )
- .verifyTextInLog( "junit-platform-launcher-1.3.1.jar" ) // is always "1.3.1" for now
- .verifyTextInLog( "opentest4j-1.0.0.jar" );
+ unpackExecuteAndVerifyVersions(versions);
}
@Test
- public void testJUnitPlatform_1_1_1()
+ public void testJUnitPlatform_1_2_0() throws VerificationException
{
- unpack( "/junit-platform-1.1.1" ).executeTest().verifyErrorFree( 1 );
+ Map<String, String> versions = new HashMap<String, String>();
+ versions.put("surefire", "2.22.1-SNAPSHOT"); // TODO Extract current from build!
+ versions.put("platform", "1.2.0");
+ versions.put("jupiter", "5.2.0");
+ versions.put("opentest", "1.1.0");
+ versions.put("apiguardian", "1.0.0");
+
+ unpackExecuteAndVerifyVersions(versions);
}
@Test
- public void testJUnitPlatform_1_2_0()
+ public void testJUnitPlatform_1_3_1() throws VerificationException
{
- unpack( "/junit-platform-1.2.0" ).executeTest().verifyErrorFree( 1 );
+ Map<String, String> versions = new HashMap<String, String>();
+ versions.put("surefire", "2.22.1-SNAPSHOT"); // TODO Extract current from build!
+ versions.put("platform", "1.3.1");
+ versions.put("jupiter", "5.3.1");
+ versions.put("opentest", "1.1.1");
+ versions.put("apiguardian", "1.0.0");
+
+ unpackExecuteAndVerifyVersions(versions);
}
@Test
@@ -103,4 +121,58 @@ public class JUnitPlatformIT
{
unpack( "/junit-platform-tags" ).executeTest().verifyErrorFree( 2 );
}
+
+ private String replaceVersions( String pattern, Map<String, String> versions )
+ {
+ String result = pattern;
+ for(Map.Entry<String, String> entry : versions.entrySet()) {
+ result = result.replace("${" + entry.getKey() + "}", entry.getValue());
+ }
+ return result;
+ }
+
+ private void unpackExecuteAndVerifyVersions(Map<String, String> versions) throws VerificationException
+ {
+ OutputValidator validator = unpack( "/junit-platform-" + versions.get("platform") )
+ .addGoal( "-X" )
+ .executeTest()
+ .verifyErrorFree( 1 );
+
+ String compactTestClasspathPattern = "[DEBUG] test(compact) classpath:"
+ + " test-classes"
+ + " classes"
+ + " junit-jupiter-engine-${jupiter}.jar"
+ + " apiguardian-api-${apiguardian}.jar"
+ + " junit-platform-engine-${platform}.jar"
+ + " junit-platform-commons-${platform}.jar"
+ + " opentest4j-${opentest}.jar"
+ + " junit-jupiter-api-${jupiter}.jar";
+ String expectedTestClasspath = replaceVersions( compactTestClasspathPattern, versions );
+ validator.assertThatLogLine( containsString( expectedTestClasspath ), is( 1 ) );
+
+ String compactProviderClasspathPattern ="[DEBUG] provider(compact) classpath:"
+ + " surefire-junit-platform-${surefire}.jar"
+ + " junit-platform-launcher-1.3.1.jar"
+ + " surefire-api-${surefire}.jar"
+ + " surefire-logger-api-${surefire}.jar";
+ String expectedProviderClasspath = replaceVersions( compactProviderClasspathPattern, versions );
+ validator.assertThatLogLine( containsString( expectedProviderClasspath ), is( 1 ) );
+
+ String compactBootClasspathPattern = "[DEBUG] boot(compact) classpath:"
+ + " surefire-booter-${surefire}.jar"
+ + " surefire-api-${surefire}.jar"
+ + " surefire-logger-api-${surefire}.jar"
+ + " test-classes"
+ + " classes"
+ + " junit-jupiter-engine-${jupiter}.jar"
+ + " apiguardian-api-${apiguardian}.jar"
+ + " junit-platform-engine-${platform}.jar"
+ + " junit-platform-commons-${platform}.jar"
+ + " opentest4j-${opentest}.jar"
+ + " junit-jupiter-api-${jupiter}.jar"
+ + " surefire-junit-platform-${surefire}.jar"
+ + " junit-platform-launcher-1.3.1.jar";
+ String expectedBootClasspath = replaceVersions( compactBootClasspathPattern, versions );
+ validator.assertThatLogLine( containsString( expectedBootClasspath ), is( 1 ) );
+ }
}
diff --git a/surefire-its/src/test/resources/junit-platform-1.3.1/pom.xml b/surefire-its/src/test/resources/junit-platform-1.3.1/pom.xml
new file mode 100644
index 0000000..f9574a7
--- /dev/null
+++ b/surefire-its/src/test/resources/junit-platform-1.3.1/pom.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.plugins.surefire</groupId>
+ <artifactId>junit-platform-1.3.1</artifactId>
+ <version>1.0</version>
+ <name>Test for JUnit 5: Platform 1.3.1 + Jupiter 5.3.1</name>
+
+ <properties>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+ </properties>
+
+ <!--
+ Declare "junit-jupiter-engine" dependency because the
+ Jupiter Engine is needed at test runtime. Artifacts
+ needed for test compilation, like "junit-jupiter-api",
+ are pulled-in via transitive dependency resolution.
+ -->
+ <dependencies>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ <version>5.3.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${surefire.version}</version>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/surefire-its/src/test/resources/junit-platform-1.3.1/src/test/java/junitplatform_1_3_1/JUnitPlatform_1_3_1_Test.java b/surefire-its/src/test/resources/junit-platform-1.3.1/src/test/java/junitplatform_1_3_1/JUnitPlatform_1_3_1_Test.java
new file mode 100644
index 0000000..1a54020
--- /dev/null
+++ b/surefire-its/src/test/resources/junit-platform-1.3.1/src/test/java/junitplatform_1_3_1/JUnitPlatform_1_3_1_Test.java
@@ -0,0 +1,37 @@
+package junitplatform_1_3_1;
+
+/*
+ * 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 static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
+
+class JUnitPlatform_1_3_1_Test
+{
+
+ @Test
+ void test(TestInfo info)
+ {
+ assertEquals( "test(TestInfo)", info.getDisplayName(), "display name mismatch" );
+ }
+
+
+}