From bb45e3ed9ea0dc03da761775df976c8fe9ea9466 Mon Sep 17 00:00:00 2001 From: norangebit Date: Sun, 14 Apr 2019 11:39:11 +0200 Subject: [PATCH] update build scripts - upgrade to gradle 5.3.1 - upgrade to junit 5 - update test for compatibility to junit 5 --- build.gradle.kts | 9 ++++++++- buildSrc/src/main/java/Config.kt | 8 +++++--- gradle/wrapper/gradle-wrapper.properties | 2 +- .../algorithms/datastructures/bag/LinkedListBagTest.kt | 8 ++++---- .../datastructures/bag/ResizingArrayBagTest.kt | 6 +++--- .../algorithms/datastructures/dictionary/MapTest.kt | 6 +++--- .../datastructures/queue/LinkedListQueueTest.kt | 6 +++--- .../datastructures/queue/ResizingArrayQueueTest.kt | 6 +++--- .../datastructures/stack/LinkedListStackTest.kt | 8 ++++---- .../datastructures/unionfind/QuickFindTest.kt | 6 +++--- .../unionfind/QuickUnionCompressionPathTest.kt | 6 +++--- .../datastructures/unionfind/QuickUnionTest.kt | 6 +++--- .../datastructures/unionfind/QuickUnionWithSizeTest.kt | 6 +++--- .../algorithms/exercises/OrderedListSorterTest.kt | 10 ++-------- 14 files changed, 48 insertions(+), 45 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 7b962de..334f030 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,6 +2,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { kotlin("jvm") version Config.Versions.kotlin + jacoco } group = "norangebit" @@ -21,8 +22,10 @@ dependencies { testImplementation(Config.Libs.junit) testImplementation(Config.Libs.kluent) testImplementation(Config.Libs.mockk) + testImplementation (Config.Libs.jetbrainJunit) // testImplementation(Config.Libs.spekDsl) + testRuntimeOnly(Config.Libs.junitEngine) // testRuntimeOnly(Config.Libs.kotlinReflect) // testRuntimeOnly(Config.Libs.spekRunner) } @@ -31,4 +34,8 @@ tasks.withType { kotlinOptions.jvmTarget = "1.8" } -tasks.register("ktlint", Ktlint::class) \ No newline at end of file +tasks.getByName("test") { + useJUnitPlatform() +} + +tasks.register("ktlint", Ktlint::class) diff --git a/buildSrc/src/main/java/Config.kt b/buildSrc/src/main/java/Config.kt index c8f6bcc..e2e7e2e 100644 --- a/buildSrc/src/main/java/Config.kt +++ b/buildSrc/src/main/java/Config.kt @@ -28,10 +28,10 @@ object Config { val arrow = "0.8.2" val kluent = "1.48" val koin = "1.0.2" - val junit = "5.1.0" + val junit = "5.4.2" val spek = "2.0.1" - val kotlin = "1.3.21" - val mockk = "1.9.2" + val kotlin = "1.3.30" + val mockk = "1.9.3" val gson = "2.8.5" } @@ -39,11 +39,13 @@ object Config { val arrowCore = "io.arrow-kt:arrow-core:${Versions.arrow}" val koin = "org.koin:koin-core:${Versions.koin}" val junit = "org.junit.jupiter:junit-jupiter-api:${Versions.junit}" + val junitEngine = "org.junit.jupiter:junit-jupiter-engine:${Versions.junit}" val kluent = "org.amshove.kluent:kluent:${Versions.kluent}" val spekDsl = "org.spekframework.spek2:spek-dsl-jvm:${Versions.spek}" val kotlinReflect = "org.jetbrains.kotlin:kotlin-reflect:${Versions.kotlin}" val spekRunner = "org.spekframework.spek2:spek-runner-junit5:${Versions.spek}" val mockk = "io.mockk:mockk:${Versions.mockk}" val gson = "com.google.code.gson:gson:${Versions.gson}" + val jetbrainJunit = "org.jetbrains.kotlin:kotlin-test-junit:${Versions.kotlin}" } } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 115e6ac..ea13fdf 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.3.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/test/kotlin/it/norangeb/algorithms/datastructures/bag/LinkedListBagTest.kt b/src/test/kotlin/it/norangeb/algorithms/datastructures/bag/LinkedListBagTest.kt index 92856c3..aa193ff 100644 --- a/src/test/kotlin/it/norangeb/algorithms/datastructures/bag/LinkedListBagTest.kt +++ b/src/test/kotlin/it/norangeb/algorithms/datastructures/bag/LinkedListBagTest.kt @@ -26,14 +26,14 @@ package it.norangeb.algorithms.datastructures.bag import org.amshove.kluent.`should be equal to` -import org.junit.Before +import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test class LinkedListBagTest { - private var bag = LinkedListBag() + private lateinit var bag :LinkedListBag - @Before - fun makeBag() { + @BeforeEach + fun init() { bag = LinkedListBag() } diff --git a/src/test/kotlin/it/norangeb/algorithms/datastructures/bag/ResizingArrayBagTest.kt b/src/test/kotlin/it/norangeb/algorithms/datastructures/bag/ResizingArrayBagTest.kt index 747cba9..c94f3c2 100644 --- a/src/test/kotlin/it/norangeb/algorithms/datastructures/bag/ResizingArrayBagTest.kt +++ b/src/test/kotlin/it/norangeb/algorithms/datastructures/bag/ResizingArrayBagTest.kt @@ -26,13 +26,13 @@ package it.norangeb.algorithms.datastructures.bag import org.amshove.kluent.`should be equal to` -import org.junit.Before +import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test class ResizingArrayBagTest { - private var bag = ResizingArrayBag() + private lateinit var bag :ResizingArrayBag - @Before + @BeforeEach fun makeBag() { bag = ResizingArrayBag() } diff --git a/src/test/kotlin/it/norangeb/algorithms/datastructures/dictionary/MapTest.kt b/src/test/kotlin/it/norangeb/algorithms/datastructures/dictionary/MapTest.kt index bbca586..3f5e44f 100644 --- a/src/test/kotlin/it/norangeb/algorithms/datastructures/dictionary/MapTest.kt +++ b/src/test/kotlin/it/norangeb/algorithms/datastructures/dictionary/MapTest.kt @@ -30,13 +30,13 @@ import arrow.core.Some import org.amshove.kluent.`should be equal to` import org.amshove.kluent.`should be` import org.amshove.kluent.should -import org.junit.Before -import org.junit.Test +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test class MapTest { lateinit var map: Dictionary - @Before + @BeforeEach fun init() { map = Map() } diff --git a/src/test/kotlin/it/norangeb/algorithms/datastructures/queue/LinkedListQueueTest.kt b/src/test/kotlin/it/norangeb/algorithms/datastructures/queue/LinkedListQueueTest.kt index 1fd4afc..43ca44d 100644 --- a/src/test/kotlin/it/norangeb/algorithms/datastructures/queue/LinkedListQueueTest.kt +++ b/src/test/kotlin/it/norangeb/algorithms/datastructures/queue/LinkedListQueueTest.kt @@ -29,13 +29,13 @@ import arrow.core.None import arrow.core.Some import arrow.core.getOrElse import org.amshove.kluent.`should be equal to` -import org.junit.Before +import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test class LinkedListQueueTest { - private var queue = LinkedListQueue() + private lateinit var queue : LinkedListQueue - @Before + @BeforeEach fun makeQueue() { queue = LinkedListQueue() } diff --git a/src/test/kotlin/it/norangeb/algorithms/datastructures/queue/ResizingArrayQueueTest.kt b/src/test/kotlin/it/norangeb/algorithms/datastructures/queue/ResizingArrayQueueTest.kt index 0c99afd..2bea52f 100644 --- a/src/test/kotlin/it/norangeb/algorithms/datastructures/queue/ResizingArrayQueueTest.kt +++ b/src/test/kotlin/it/norangeb/algorithms/datastructures/queue/ResizingArrayQueueTest.kt @@ -29,13 +29,13 @@ import arrow.core.None import arrow.core.Some import arrow.core.getOrElse import org.amshove.kluent.`should be equal to` -import org.junit.Before +import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test class ResizingArrayQueueTest { - private var queue = ResizingArrayQueue() + private lateinit var queue : ResizingArrayQueue - @Before + @BeforeEach fun makeQueue() { queue = ResizingArrayQueue() } diff --git a/src/test/kotlin/it/norangeb/algorithms/datastructures/stack/LinkedListStackTest.kt b/src/test/kotlin/it/norangeb/algorithms/datastructures/stack/LinkedListStackTest.kt index 3f91f2c..9635af4 100644 --- a/src/test/kotlin/it/norangeb/algorithms/datastructures/stack/LinkedListStackTest.kt +++ b/src/test/kotlin/it/norangeb/algorithms/datastructures/stack/LinkedListStackTest.kt @@ -28,14 +28,14 @@ package it.norangeb.algorithms.datastructures.stack import arrow.core.None import arrow.core.getOrElse import org.amshove.kluent.`should be equal to` -import org.junit.Before +import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test class LinkedListStackTest { - private var stack = LinkedListStack() + private lateinit var stack : LinkedListStack - @Before - fun makeStack() { + @BeforeEach + fun init() { stack = LinkedListStack() } diff --git a/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickFindTest.kt b/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickFindTest.kt index 948f1a9..986a886 100644 --- a/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickFindTest.kt +++ b/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickFindTest.kt @@ -26,13 +26,13 @@ package it.norangeb.algorithms.datastructures.unionfind import org.amshove.kluent.`should be equal to` -import org.junit.Before +import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test class QuickFindTest { - private var unionFind = QuickFind(10) + private lateinit var unionFind : QuickFind - @Before + @BeforeEach fun init() { unionFind = QuickFind(10) } diff --git a/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickUnionCompressionPathTest.kt b/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickUnionCompressionPathTest.kt index 082f897..885e31c 100644 --- a/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickUnionCompressionPathTest.kt +++ b/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickUnionCompressionPathTest.kt @@ -26,13 +26,13 @@ package it.norangeb.algorithms.datastructures.unionfind import org.amshove.kluent.`should be equal to` -import org.junit.Before +import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test class QuickUnionCompressionPathTest { - private var unionFind = QuickUnion(10) + private lateinit var unionFind : QuickUnion - @Before + @BeforeEach fun init() { unionFind = QuickUnion(10) } diff --git a/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickUnionTest.kt b/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickUnionTest.kt index cd0c51f..1d500b3 100644 --- a/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickUnionTest.kt +++ b/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickUnionTest.kt @@ -26,13 +26,13 @@ package it.norangeb.algorithms.datastructures.unionfind import org.amshove.kluent.`should be equal to` -import org.junit.Before +import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test class QuickUnionTest { - private var unionFind = QuickUnion(10) + private lateinit var unionFind : QuickUnion - @Before + @BeforeEach fun init() { unionFind = QuickUnion(10) } diff --git a/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickUnionWithSizeTest.kt b/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickUnionWithSizeTest.kt index dcf811b..f388811 100644 --- a/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickUnionWithSizeTest.kt +++ b/src/test/kotlin/it/norangeb/algorithms/datastructures/unionfind/QuickUnionWithSizeTest.kt @@ -26,13 +26,13 @@ package it.norangeb.algorithms.datastructures.unionfind import org.amshove.kluent.`should be equal to` -import org.junit.Before +import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test class QuickUnionWithSizeTest { - private var unionFind = QuickUnionWithSize(10) + private lateinit var unionFind : QuickUnionWithSize - @Before + @BeforeEach fun init() { unionFind = QuickUnionWithSize(10) } diff --git a/src/test/kotlin/it/norangeb/algorithms/exercises/OrderedListSorterTest.kt b/src/test/kotlin/it/norangeb/algorithms/exercises/OrderedListSorterTest.kt index 0e5ab10..9cda8f4 100644 --- a/src/test/kotlin/it/norangeb/algorithms/exercises/OrderedListSorterTest.kt +++ b/src/test/kotlin/it/norangeb/algorithms/exercises/OrderedListSorterTest.kt @@ -26,22 +26,16 @@ package it.norangeb.algorithms.exercises import org.amshove.kluent.`should equal` -import org.junit.Before -import org.junit.Test +import org.junit.jupiter.api.Test class OrderedListSorterTest { - lateinit var lists: List> - - @Before - fun init() { - lists = listOf( + val lists = listOf( listOf(1, 5, 9, 10, 12, 14, 15, 15, 20, 25, 29, 31, 35, 37, 43, 48), listOf(2, 7, 12, 21, 23, 33, 35, 43, 45), listOf(3, 7, 9, 12, 14, 16, 27, 28, 37, 39, 45, 45, 46, 50), listOf(1, 8, 9, 11, 13, 21, 25, 33, 34, 41, 47, 48) ) - } @Test fun testSortUnsignedInt() {