Switch to JUnit 5 as test runner

This commit is contained in:
Brian Norman
2021-11-26 14:02:24 -06:00
parent 2e5de9f58e
commit e346df26d3
10 changed files with 22 additions and 14 deletions
+5 -1
View File
@@ -15,7 +15,7 @@ dependencies {
kapt("com.google.auto.service:auto-service:1.0.1")
compileOnly("com.google.auto.service:auto-service-annotations:1.0.1")
testImplementation(kotlin("test-junit"))
testImplementation(kotlin("test-junit5"))
testImplementation("org.jetbrains.kotlin:kotlin-compiler-embeddable")
testImplementation("com.github.tschuchortdev:kotlin-compile-testing:1.4.6")
}
@@ -24,6 +24,10 @@ tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.dokka {
outputFormat = "html"
outputDirectory = "$buildDir/javadoc"
@@ -16,7 +16,7 @@
package com.bnorm.power
import org.junit.Test
import kotlin.test.Test
import kotlin.test.assertEquals
class ArithmeticExpressionTest {
@@ -16,8 +16,8 @@
package com.bnorm.power
import kotlin.test.Test
import org.jetbrains.kotlin.name.FqName
import org.junit.Test
class AssertLibraryTest {
@Test
@@ -111,7 +111,7 @@ class AssertLibraryTest {
assertEquals(greeting, name)
| |
| World
Hello expected:<[Hello]> but was:<[World]>
Hello ==> expected: <Hello> but was: <World>
""".trimIndent(),
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertEquals")))
)
@@ -133,7 +133,7 @@ class AssertLibraryTest {
assertEquals(greeting, name, "Message:")
| |
| World
Hello expected:<[Hello]> but was:<[World]>
Hello ==> expected: <Hello> but was: <World>
""".trimIndent(),
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertEquals")))
)
@@ -152,7 +152,7 @@ class AssertLibraryTest {
"""
assertNotNull(name)
|
null
null ==> expected: not <null>
""".trimIndent(),
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertNotNull")))
)
@@ -172,7 +172,7 @@ class AssertLibraryTest {
Message:
assertNotNull(name, "Message:")
|
null
null ==> expected: not <null>
""".trimIndent(),
PowerAssertComponentRegistrar(setOf(FqName("kotlin.test.assertNotNull")))
)
@@ -19,10 +19,10 @@ package com.bnorm.power
import com.tschuchort.compiletesting.KotlinCompilation
import com.tschuchort.compiletesting.SourceFile
import org.jetbrains.kotlin.name.FqName
import org.junit.Test
import java.io.ByteArrayOutputStream
import java.io.PrintStream
import java.lang.reflect.InvocationTargetException
import kotlin.test.Test
import kotlin.test.assertEquals
class DebugFunctionTest {
@@ -16,8 +16,8 @@
package com.bnorm.power
import kotlin.test.Test
import org.jetbrains.kotlin.name.FqName
import org.junit.Test
class LamdaTest {
@Test
@@ -19,10 +19,10 @@ package com.bnorm.power
import com.tschuchort.compiletesting.KotlinCompilation
import com.tschuchort.compiletesting.SourceFile
import org.jetbrains.kotlin.name.FqName
import org.junit.Test
import java.io.ByteArrayOutputStream
import java.io.PrintStream
import java.lang.reflect.InvocationTargetException
import kotlin.test.Test
import kotlin.test.assertEquals
class MultiParameterFunctionTest {
@@ -16,7 +16,7 @@
package com.bnorm.power
import org.junit.Test
import kotlin.test.Test
import kotlin.test.assertEquals
class RegexMatchTest {
@@ -62,7 +62,7 @@ fun executeAssertion(
}
fail("should have thrown assertion")
} catch (t: Throwable) {
return t.message!!
return t.message ?: ""
}
}
@@ -16,8 +16,8 @@
package com.bnorm.power
import kotlin.test.Test
import org.jetbrains.kotlin.name.FqName
import org.junit.Test
class CompilerTest {
@Test
+5 -1
View File
@@ -32,7 +32,7 @@ kotlin {
}
val jvmTest by getting {
dependencies {
implementation(kotlin("test-junit"))
implementation(kotlin("test-junit5"))
}
}
val jsTest by getting {
@@ -49,6 +49,10 @@ kotlin {
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
configure<com.bnorm.power.PowerAssertGradleExtension> {
functions = listOf(
"kotlin.assert",