Skip to content

Commit 73659b8

Browse files
committed
Update to JUnit 6.0.0
1 parent bf744e6 commit 73659b8

File tree

5 files changed

+25
-35
lines changed

5 files changed

+25
-35
lines changed

BotCommands-core/src/test/kotlin/io/github/freya022/botcommands/components/ComponentTests.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import io.github.freya022.botcommands.helpers.config.Environment
1111
import io.github.freya022.botcommands.helpers.db.TestH2Source
1212
import io.github.freya022.botcommands.helpers.utils.createTest
1313
import io.github.freya022.botcommands.internal.components.controller.ComponentController
14-
import kotlinx.coroutines.runBlocking
1514
import org.junit.jupiter.api.Assertions.assertNull
1615
import org.junit.jupiter.api.BeforeAll
1716
import org.junit.jupiter.api.Test
@@ -36,7 +35,7 @@ object ComponentTests {
3635
}
3736

3837
@Test
39-
fun `Group delete results in owned components deleted`(): Unit = runBlocking {
38+
suspend fun `Group delete results in owned components deleted`() {
4039
val button = buttons.primary("test").persistent { }
4140
val group = buttons.group(button).ephemeral { }
4241

@@ -47,7 +46,7 @@ object ComponentTests {
4746
}
4847

4948
@Test
50-
fun `Component delete results in owner group deleted`(): Unit = runBlocking {
49+
suspend fun `Component delete results in owner group deleted`() {
5150
val button = buttons.primary("test").persistent { }
5251
val group = buttons.group(button).ephemeral { }
5352

BotCommands-core/src/test/kotlin/io/github/freya022/botcommands/modals/ModalInputResolverTests.kt

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import io.github.freya022.botcommands.internal.modals.resolvers.ModalStringResol
1717
import io.github.freya022.botcommands.internal.parameters.ResolverContainer
1818
import io.mockk.every
1919
import io.mockk.mockk
20-
import kotlinx.coroutines.runBlocking
2120
import net.dv8tion.jda.api.entities.*
2221
import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel
2322
import net.dv8tion.jda.api.interactions.modals.ModalMapping
@@ -57,7 +56,7 @@ object ModalInputResolverTests {
5756

5857
@MethodSource("modalInputs")
5958
@ParameterizedTest
60-
fun `Modal input parameter can be resolved`(index: Int, expected: Any?) {
59+
suspend fun `Modal input parameter can be resolved`(index: Int, expected: Any?) {
6160
val serviceContainer = mockk<ServiceContainer> {
6261
every { getServiceNamesForAnnotation(Resolver::class) } returns listOf(
6362
"modalMentionsResolver",
@@ -84,13 +83,11 @@ object ModalInputResolverTests {
8483
every { asMentions } returns mentions
8584
}
8685

87-
val value = runBlocking {
88-
resolver.resolveSuspend(
89-
mockk<ModalOption>(),
90-
mockk<ModalEvent>(),
91-
modalMapping,
92-
)
93-
}
86+
val value = resolver.resolveSuspend(
87+
mockk<ModalOption>(),
88+
mockk<ModalEvent>(),
89+
modalMapping,
90+
)
9491

9592
assertEquals(expected, value)
9693
}

BotCommands-jda-ktx/src/test/kotlin/dev/freya02/botcommands/jda/ktx/RestResultTest.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package dev.freya02.botcommands.jda.ktx
33
import dev.freya02.botcommands.jda.ktx.requests.awaitCatching
44
import dev.freya02.botcommands.jda.ktx.requests.ignore
55
import dev.freya02.botcommands.jda.ktx.requests.recover
6-
import kotlinx.coroutines.runBlocking
76
import net.dv8tion.jda.api.exceptions.ErrorResponseException
87
import net.dv8tion.jda.api.requests.ErrorResponse
98
import net.dv8tion.jda.api.requests.Response
@@ -19,7 +18,7 @@ object RestResultTest {
1918
}
2019

2120
@Test
22-
fun `Recover error response`() = runBlocking {
21+
suspend fun `Recover error response`() {
2322
val restResult = restException()
2423
.awaitCatching()
2524
.recover(ErrorResponse.ALREADY_CROSSPOSTED) {
@@ -33,7 +32,7 @@ object RestResultTest {
3332
}
3433

3534
@Test
36-
fun `Ignore error responses`() = runBlocking {
35+
suspend fun `Ignore error responses`() {
3736
val restResult = restException()
3837
.awaitCatching()
3938
.ignore(ErrorResponse.ALREADY_CROSSPOSTED)
@@ -45,7 +44,7 @@ object RestResultTest {
4544
}
4645

4746
@Test
48-
fun `Handle error responses`() = runBlocking {
47+
suspend fun `Handle error responses`() {
4948
val restResult = restException()
5049
.awaitCatching()
5150
.ignore(ErrorResponse.ALREADY_CROSSPOSTED)

BotCommands-method-accessors/src/test/kotlin/dev/freya02/botcommands/method/accessors/MethodAccessorTest.kt

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import dev.freya02.botcommands.method.accessors.internal.KotlinReflectMethodAcce
55
import dev.freya02.botcommands.method.accessors.internal.MethodAccessorFactory
66
import dev.freya02.botcommands.method.accessors.internal.exceptions.IllegalSuspendCallException
77
import kotlinx.coroutines.delay
8-
import kotlinx.coroutines.runBlocking
98
import org.junit.jupiter.api.assertDoesNotThrow
109
import org.junit.jupiter.api.assertThrows
1110
import org.junit.jupiter.params.ParameterizedTest
@@ -19,28 +18,24 @@ object MethodAccessorTest {
1918

2019
@MethodSource("testCallers")
2120
@ParameterizedTest
22-
fun `Generate ClassFile method accessors and call them`(instance: Any?, function: KFunction<*>, args: List<Any?>) {
23-
runBlocking {
24-
val methodAccessor = ClassFileMethodAccessorFactory().create(instance, function)
25-
val args = methodAccessor.createBlankArguments().also {
26-
args.forEach { arg -> it.push(arg) }
27-
}
28-
29-
methodAccessor.callSuspend(args)
21+
suspend fun `Generate ClassFile method accessors and call them`(instance: Any?, function: KFunction<*>, args: List<Any?>) {
22+
val methodAccessor = ClassFileMethodAccessorFactory().create(instance, function)
23+
val args = methodAccessor.createBlankArguments().also {
24+
args.forEach { arg -> it.push(arg) }
3025
}
26+
27+
methodAccessor.callSuspend(args)
3128
}
3229

3330
@MethodSource("testCallers")
3431
@ParameterizedTest
35-
fun `Generate kotlin-reflect method accessors and call them`(instance: Any?, function: KFunction<*>, args: List<Any?>) {
36-
runBlocking {
37-
val methodAccessor = KotlinReflectMethodAccessorFactory().create(instance, function)
38-
val args = methodAccessor.createBlankArguments().also {
39-
args.forEach { arg -> it.push(arg) }
40-
}
41-
42-
methodAccessor.callSuspend(args)
32+
suspend fun `Generate kotlin-reflect method accessors and call them`(instance: Any?, function: KFunction<*>, args: List<Any?>) {
33+
val methodAccessor = KotlinReflectMethodAccessorFactory().create(instance, function)
34+
val args = methodAccessor.createBlankArguments().also {
35+
args.forEach { arg -> it.push(arg) }
4336
}
37+
38+
methodAccessor.callSuspend(args)
4439
}
4540

4641
@JvmStatic
@@ -102,7 +97,7 @@ object MethodAccessorTest {
10297

10398
@MethodSource("factories")
10499
@ParameterizedTest
105-
fun `Coroutine return type of inline class returns an inline class instance`(factory: MethodAccessorFactory) = runBlocking {
100+
suspend fun `Coroutine return type of inline class returns an inline class instance`(factory: MethodAccessorFactory) {
106101
val accessor = factory.create(TestClass(), TestClass::coRunWithInlineClassReturnType as KFunction<*>)
107102
val result = accessor.callSuspend(accessor.createBlankArguments())
108103
assertIs<InlineDouble>(result)

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jemoji = "1.7.4"
1717
jetbrains-annotations = "26.0.2"
1818
jetbrains-markdown = "0.7.3"
1919
jsr305 = "3.0.2"
20-
junit = "5.13.4"
20+
junit = "6.0.0"
2121
konsist = "0.17.3"
2222
kotlin = "2.2.20"
2323
kotlin-logging = "7.0.3"

0 commit comments

Comments
 (0)