Reuse Junit4VersionsIT to also test JUnit 5
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/8995a289 Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/8995a289 Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/8995a289 Branch: refs/heads/junit5 Commit: 8995a2894488d6ca3796f274498b1516cd2ed131 Parents: 108538b Author: Benedikt Ritter <brit...@apache.org> Authored: Sun Oct 9 14:43:20 2016 +0200 Committer: Benedikt Ritter <brit...@apache.org> Committed: Sat Nov 19 14:02:07 2016 +0100 ---------------------------------------------------------------------- .../maven/surefire/its/JUnit4VersionsIT.java | 23 +++- .../src/test/resources/junit4/pom.xml | 108 ++++++++++++++----- 2 files changed, 104 insertions(+), 27 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/8995a289/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit4VersionsIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit4VersionsIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit4VersionsIT.java index 8dd8f0c..bb216d3 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit4VersionsIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit4VersionsIT.java @@ -31,6 +31,9 @@ import org.junit.runners.Parameterized.Parameter; import static org.junit.runners.Parameterized.*; +import static org.apache.commons.lang3.JavaVersion.JAVA_1_8; +import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion; + /** * Basic suite test using all known versions of JUnit 4.x * @@ -79,9 +82,27 @@ public class JUnit4VersionsIT runJUnitTest( version ); } + @Test + public void test500M2() + throws Exception + { + assumeJavaVersion( JAVA_1_8 ); + + runJUnitTest( "5.0.0-M2" ); + } + public void runJUnitTest( String version ) throws Exception { - unpack().setJUnitVersion( version ).executeTest().verifyErrorFree( 1 ); + unpack().setJUnitVersion( version ).activateProfile( getProfile( version ) ).executeTest().verifyErrorFree( 1 ); + } + + private String getProfile( String version ) + { + if ( version.startsWith( "4" ) ) + { + return "junit4"; + } + return "junit5"; } } http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/8995a289/surefire-integration-tests/src/test/resources/junit4/pom.xml ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/resources/junit4/pom.xml b/surefire-integration-tests/src/test/resources/junit4/pom.xml index c10d8e9..1dd57b0 100644 --- a/surefire-integration-tests/src/test/resources/junit4/pom.xml +++ b/surefire-integration-tests/src/test/resources/junit4/pom.xml @@ -28,31 +28,87 @@ <version>1.0-SNAPSHOT</version> <name>Test for JUnit 4</name> - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>${junit.version}</version> - <scope>test</scope> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <configuration> - <source>1.5</source> - <target>1.5</target> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <version>${surefire.version}</version> - </plugin> - </plugins> - </build> + <profiles> + <profile> + <id>junit4</id> + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>${junit.version}</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.5</source> + <target>1.5</target> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>${surefire.version}</version> + </plugin> + </plugins> + </build> + </profile> + + <profile> + <id>junit5</id> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <java.version>1.8</java.version> + <junit.jupiter.version>5.0.0-M2</junit.jupiter.version> + <junit.vintage.version>4.12.0-M2</junit.vintage.version> + <junit.platform.version>1.0.0-M2</junit.platform.version> + </properties> + + <dependencies> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-engine</artifactId> + <version>${junit.jupiter.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.junit.vintage</groupId> + <artifactId>junit-vintage-engine</artifactId> + <version>${junit.vintage.version}</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>${java.version}</source> + <target>${java.version}</target> + </configuration> + </plugin> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <version>${surefire.version}</version> + <dependencies> + <dependency> + <groupId>org.junit.platform</groupId> + <artifactId>junit-platform-surefire-provider</artifactId> + <version>${junit.platform.version}</version> + </dependency> + </dependencies> + </plugin> + </plugins> + </build> + </profile> + </profiles> + </project>