You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2016/12/02 04:03:07 UTC

[5/7] maven-surefire git commit: Sure one test among JUnit 4 and JUnit 5

Sure one test among JUnit 4 and 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/a50c823b
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/a50c823b
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/a50c823b

Branch: refs/heads/junit5
Commit: a50c823baba16f0bc5e4b7c08993d1bf706ce1dc
Parents: 81f3dda
Author: Benedikt Ritter <br...@apache.org>
Authored: Mon Oct 10 19:04:24 2016 +0200
Committer: Benedikt Ritter <br...@apache.org>
Committed: Sat Nov 19 14:02:17 2016 +0100

----------------------------------------------------------------------
 .../src/test/resources/junit4/pom.xml           | 24 +++++---
 .../junit4/src/test/java/junit5/JUnit5Test.java | 65 ++++++++++++++++++++
 2 files changed, 81 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/a50c823b/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 f277ceb..57e66b8 100644
--- a/surefire-integration-tests/src/test/resources/junit4/pom.xml
+++ b/surefire-integration-tests/src/test/resources/junit4/pom.xml
@@ -28,14 +28,28 @@
   <version>1.0-SNAPSHOT</version>
   <name>Test for JUnit 4</name>
 
+  <dependencies>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-api</artifactId>
+      <version>5.0.0-M2</version>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.12</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
   <build>
     <plugins>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-compiler-plugin</artifactId>
         <configuration>
-          <source>${java.version}</source>
-          <target>${java.version}</target>
+          <source>1.8</source>
+          <target>1.8</target>
         </configuration>
       </plugin>
     </plugins>
@@ -45,10 +59,6 @@
     <profile>
       <id>junit4</id>
 
-      <properties>
-        <java.version>1.5</java.version>
-      </properties>
-
       <dependencies>
         <dependency>
           <groupId>junit</groupId>
@@ -74,7 +84,6 @@
 
       <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>
@@ -111,7 +120,6 @@
 
       <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <java.version>1.8</java.version>
         <junit.platform.version>1.0.0-M2</junit.platform.version>
       </properties>
 

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/a50c823b/surefire-integration-tests/src/test/resources/junit4/src/test/java/junit5/JUnit5Test.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/junit4/src/test/java/junit5/JUnit5Test.java b/surefire-integration-tests/src/test/resources/junit4/src/test/java/junit5/JUnit5Test.java
new file mode 100644
index 0000000..558546d
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/junit4/src/test/java/junit5/JUnit5Test.java
@@ -0,0 +1,65 @@
+package junit5;
+
+/*
+ * 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.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+
+/**
+ * A test using the JUnit 5 API, which should be executed by JUnit jupiter enigne
+ */
+public class JUnit5Test
+{
+
+    private boolean setUpCalled;
+
+    private static boolean tearDownCalled;
+
+    @BeforeEach
+    public void setUp()
+    {
+        setUpCalled = true;
+        System.out.println( "Called setUp" );
+    }
+
+    @AfterEach
+    public void tearDown()
+    {
+        tearDownCalled = true;
+        System.out.println( "Called tearDown" );
+    }
+
+    @Test
+    public void testSetUp()
+    {
+        Assertions.assertTrue( setUpCalled, "setUp was not called" );
+    }
+
+    @AfterAll
+    public static void oneTimeTearDown()
+    {
+        Assertions.assertTrue( tearDownCalled, "tearDown was not called" );
+    }
+
+}