diff --git a/core-kotlin/pom.xml b/core-kotlin/pom.xml
index 856a37ded0..e795d1e042 100644
--- a/core-kotlin/pom.xml
+++ b/core-kotlin/pom.xml
@@ -5,6 +5,7 @@
core-kotlin
1.0-SNAPSHOT
+ jar
com.baeldung
@@ -20,6 +21,24 @@
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ ${junit.jupiter.version}
+ test
+
+
+ org.junit.platform
+ junit-platform-runner
+ ${junit.platform.version}
+ test
+
+
+ junit
+ junit
+ ${junit4.version}
+ test
+
org.jetbrains.kotlin
kotlin-stdlib
@@ -116,16 +135,51 @@
+
+ maven-surefire-plugin
+ ${maven-surefire-plugin.version}
+
+
+ maven-failsafe-plugin
+ 2.19.1
+
+
+ org.junit.platform
+ junit-platform-surefire-provider
+ ${junit.platform.version}
+
+
+
+
+ junit5
+
+ integration-test
+ verify
+
+
+
+ **/*Test5.java
+
+
+
+
+
+ UTF-8
1.1.2
1.1.2
1.1.2
1.1.2
0.15
1.5.0
+
+ 5.0.0
+ 1.0.0
+ 4.12.0
+ 4.12
-
\ No newline at end of file
+
diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/Calculator.kt b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/Calculator.kt
new file mode 100644
index 0000000000..1b61c05887
--- /dev/null
+++ b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/Calculator.kt
@@ -0,0 +1,17 @@
+package com.baeldung.kotlin.junit5
+
+class Calculator {
+ fun add(a: Int, b: Int) = a + b
+
+ fun divide(a: Int, b: Int) = if (b == 0) {
+ throw DivideByZeroException(a)
+ } else {
+ a / b
+ }
+
+ fun square(a: Int) = a * a
+
+ fun squareRoot(a: Int) = Math.sqrt(a.toDouble())
+
+ fun log(base: Int, value: Int) = Math.log(value.toDouble()) / Math.log(base.toDouble())
+}
diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/CalculatorTest5.kt b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/CalculatorTest5.kt
new file mode 100644
index 0000000000..dd35805044
--- /dev/null
+++ b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/CalculatorTest5.kt
@@ -0,0 +1,82 @@
+package com.baeldung.kotlin.junit5
+
+import org.junit.jupiter.api.*
+import org.junit.jupiter.api.function.Executable
+
+class CalculatorTest5 {
+ private val calculator = Calculator()
+
+ @Test
+ fun testAddition() {
+ Assertions.assertEquals(4, calculator.add(1, 3))
+ }
+
+ @Test
+ fun testDivideByZero() {
+ val exception = Assertions.assertThrows(DivideByZeroException::class.java) {
+ calculator.divide(5, 0)
+ }
+
+ Assertions.assertEquals(5, exception.numerator)
+ }
+
+ @Test
+ fun testSquares() {
+ Assertions.assertAll(
+ Executable { Assertions.assertEquals(1, calculator.square(1)) },
+ Executable { Assertions.assertEquals(4, calculator.square(2)) },
+ Executable { Assertions.assertEquals(9, calculator.square(3)) }
+ )
+ }
+
+ @TestFactory
+ fun testSquaresFactory() = listOf(
+ DynamicTest.dynamicTest("1 squared") { Assertions.assertEquals(1,calculator.square(1))},
+ DynamicTest.dynamicTest("2 squared") { Assertions.assertEquals(4,calculator.square(2))},
+ DynamicTest.dynamicTest("3 squared") { Assertions.assertEquals(9,calculator.square(3))}
+ )
+
+ @TestFactory
+ fun testSquaresFactory2() = listOf(
+ 1 to 1,
+ 2 to 4,
+ 3 to 9,
+ 4 to 16,
+ 5 to 25)
+ .map { (input, expected) ->
+ DynamicTest.dynamicTest("$input squared") {
+ Assertions.assertEquals(expected, calculator.square(input))
+ }
+ }
+
+ private val squaresTestData = listOf(
+ 1 to 1,
+ 2 to 4,
+ 3 to 9,
+ 4 to 16,
+ 5 to 25)
+
+ @TestFactory
+ fun testSquaresFactory3() = squaresTestData
+ .map { (input, expected) ->
+ DynamicTest.dynamicTest("$input squared") {
+ Assertions.assertEquals(expected, calculator.square(input))
+ }
+ }
+ @TestFactory
+ fun testSquareRootsFactory3() = squaresTestData
+ .map { (expected, input) ->
+ DynamicTest.dynamicTest("Square root of $input") {
+ Assertions.assertEquals(expected.toDouble(), calculator.squareRoot(input))
+ }
+ }
+
+ @Tags(
+ Tag("slow"),
+ Tag("logarithms")
+ )
+ @Test
+ fun testLogarithms() {
+ Assertions.assertEquals(3.0, calculator.log(2, 8))
+ }
+}
diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/DivideByZeroException.kt b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/DivideByZeroException.kt
new file mode 100644
index 0000000000..60bc4e2944
--- /dev/null
+++ b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/DivideByZeroException.kt
@@ -0,0 +1,3 @@
+package com.baeldung.kotlin.junit5
+
+class DivideByZeroException(val numerator: Int) : Exception()
diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/SimpleTest5.kt b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/SimpleTest5.kt
new file mode 100644
index 0000000000..c04ab568f7
--- /dev/null
+++ b/core-kotlin/src/test/kotlin/com/baeldung/kotlin/junit5/SimpleTest5.kt
@@ -0,0 +1,21 @@
+package com.baeldung.kotlin.junit5
+
+import org.junit.jupiter.api.Assertions
+import org.junit.jupiter.api.Disabled
+import org.junit.jupiter.api.Test
+
+class SimpleTest5 {
+ @Test
+ fun testEmpty() {
+ val list = listOf()
+ Assertions.assertTrue(list::isEmpty)
+ }
+
+ @Test
+ @Disabled
+ fun testMessage() {
+ Assertions.assertEquals(3, 4) {
+ "Three does not equal four"
+ }
+ }
+}