switch to JUnit5 v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Mon, 04 Mar 2019 22:20:36 +0100
branchv_0
changeset 241 f332033ed66c
parent 240 09c72e23c895
child 242 0503996934e0
switch to JUnit5
java/sql-dk/pom.xml
java/sql-dk/src/test/java/info/globalcode/sql/dk/CLIParserTest.java
java/sql-dk/src/test/java/info/globalcode/sql/dk/FunctionsTest.java
--- a/java/sql-dk/pom.xml	Mon Mar 04 22:11:11 2019 +0100
+++ b/java/sql-dk/pom.xml	Mon Mar 04 22:20:36 2019 +0100
@@ -6,21 +6,28 @@
 	<version>0.10-SNAPSHOT</version>
 	<packaging>jar</packaging>
 	
-	<dependencies>
-		<dependency>
-			<groupId>org.testng</groupId>
-			<artifactId>testng</artifactId>
-			<version>6.9.9</version>
-			<scope>test</scope>
-		</dependency>
-	</dependencies>
-	
 	<properties>
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 		<maven.compiler.source>1.8</maven.compiler.source>
 		<maven.compiler.target>1.8</maven.compiler.target>
+		<junit.version>5.4.0</junit.version>
 	</properties>
 	
+	<dependencies>
+		<dependency>
+			<groupId>org.junit.jupiter</groupId>
+			<artifactId>junit-jupiter-engine</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.junit.jupiter</groupId>
+			<artifactId>junit-jupiter-params</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+	</dependencies>
+	
 	<build>
 		<plugins>
 			<plugin>
@@ -63,6 +70,22 @@
 					</execution>
 				</executions>
 			</plugin>
+			<plugin>
+				<!--
+					Without this, tests are executed as „POJO Tests“ instead of „JUnit5 Tests“
+					and @BeforeEach annotation does not work.
+					http://maven.apache.org/surefire/maven-surefire-plugin/examples/pojo-test.html
+				-->
+				<artifactId>maven-surefire-plugin</artifactId>
+				<version>2.22.0</version>
+				<dependencies>
+					<dependency>
+						<groupId>org.junit.platform</groupId>
+						<artifactId>junit-platform-surefire-provider</artifactId>
+						<version>1.2.0</version>
+					</dependency>
+				</dependencies>
+			</plugin>
 		</plugins>
 	</build>
 	
--- a/java/sql-dk/src/test/java/info/globalcode/sql/dk/CLIParserTest.java	Mon Mar 04 22:11:11 2019 +0100
+++ b/java/sql-dk/src/test/java/info/globalcode/sql/dk/CLIParserTest.java	Mon Mar 04 22:20:36 2019 +0100
@@ -22,9 +22,9 @@
 import info.globalcode.sql.dk.InfoLister.InfoType;
 import java.io.ByteArrayInputStream;
 import java.util.Collection;
-import static org.testng.Assert.*;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
 
 /**
  *
@@ -42,7 +42,7 @@
 	private static final String NAME_3 = "param3";
 	private CLIParser parser;
 
-	@BeforeMethod
+	@BeforeEach
 	public void setUpMethod() throws Exception {
 		parser = new CLIParser();
 	}
--- a/java/sql-dk/src/test/java/info/globalcode/sql/dk/FunctionsTest.java	Mon Mar 04 22:11:11 2019 +0100
+++ b/java/sql-dk/src/test/java/info/globalcode/sql/dk/FunctionsTest.java	Mon Mar 04 22:20:36 2019 +0100
@@ -20,8 +20,8 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
-import static org.testng.Assert.*;
-import org.testng.annotations.*;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
 
 /**
  *