0

実行時にこれを取得してNoClassDefFoundErrorいます(Intellijまたは経由でテストを実行しますgradlew test

これが私の簡単なテストです(KotlinとKotestの新機能)

class AuthenticationValidatorServiceTest : StringSpec({
    val userRepository = mockk<UserRepository>()
    val userTypeRepository = mockk<UserTypeRepository>()
    val accessTokenRepository  = mockk<AccessTokenRepository>()
    lateinit var service: AuthenticationValidatorService

    beforeTest {
        service = AuthenticationValidatorService(userRepository, userTypeRepository, accessTokenRepository)
    }

    "Should throw ResourceNotFoundException" {
        shouldThrow<ResourceNotFoundException> {
            val userId = UUID.randomUUID()

            every { userRepository.findById(userId) } returns Optional.empty()
            service.validateUser(userId)
        }
    }
})

私のgradleファイルに設定していないものはありますか? これが依存関係を追加しただけです

tasks.withType(Test) {
    useJUnitPlatform()
}

これらのエラーの取得

> Task :test
WARNING: ExecutionInvokerPatcher failed: java.lang.ClassNotFoundException: org.junit.jupiter.engine.descriptor.ClassTestDescriptor

Expected exception lock.http.exception.ResourceNotFoundException but a NoClassDefFoundError was thrown instead.
java.lang.AssertionError: Expected exception lock.http.exception.ResourceNotFoundException but a NoClassDefFoundError was thrown instead.
    at lock.http.service.AuthenticationValidatorServiceTest$1$2.invokeSuspend(AuthenticationValidatorServiceTest.kt:54)
    at lock.http.service.AuthenticationValidatorServiceTest$1$2.invoke(AuthenticationValidatorServiceTest.kt)
    at lock.http.service.AuthenticationValidatorServiceTest$1$2.invoke(AuthenticationValidatorServiceTest.kt)
    at io.kotest.core.spec.style.scopes.StringSpecRootContext$invoke$1.invokeSuspend(StringSpecRootContext.kt:66)
    at io.kotest.core.spec.style.scopes.StringSpecRootContext$invoke$1.invoke(StringSpecRootContext.kt)
    at io.kotest.core.spec.style.scopes.StringSpecRootContext$invoke$1.invoke(StringSpecRootContext.kt)
    at io.kotest.core.internal.ExecutionsKt$executeWithBehaviours$2$1.invokeSuspend(executions.kt:13)
    at io.kotest.core.internal.ExecutionsKt$executeWithBehaviours$2$1.invoke(executions.kt)
    at io.kotest.core.internal.ExecutionsKt$executeWithBehaviours$2$1.invoke(executions.kt)
    at io.kotest.core.internal.ExecutionsKt.wrapTestWithGlobalAssert(executions.kt:39)
    at io.kotest.core.internal.ExecutionsKt.access$wrapTestWithGlobalAssert(executions.kt:1)
    at io.kotest.core.internal.ExecutionsKt$executeWithBehaviours$2.invokeSuspend(executions.kt:12)
    at io.kotest.core.internal.ExecutionsKt$executeWithBehaviours$2.invoke(executions.kt)
    at io.kotest.core.internal.ExecutionsKt$executeWithBehaviours$2.invoke(executions.kt)
    at io.kotest.core.internal.ExecutionsKt$wrapTestWithAssertionModeCheck$2.invokeSuspend(executions.kt:25)
    at io.kotest.core.internal.ExecutionsKt$wrapTestWithAssertionModeCheck$2.invoke(executions.kt)
    at io.kotest.core.internal.ExecutionsKt$wrapTestWithAssertionModeCheck$2.invoke(executions.kt)
    at io.kotest.core.internal.AssertionsCheckKt.executeWithAssertionsCheck(assertionsCheck.kt:25)
    at io.kotest.core.internal.ExecutionsKt.wrapTestWithAssertionModeCheck(executions.kt:24)
    at io.kotest.core.internal.ExecutionsKt.executeWithBehaviours(executions.kt:11)
    at io.kotest.core.internal.TestCaseExecutor$executeInScope$2.invokeSuspend(TestCaseExecutor.kt:268)
    at io.kotest.core.internal.TestCaseExecutor$executeInScope$2.invoke(TestCaseExecutor.kt)
    at io.kotest.core.internal.TestCaseExecutor$executeInScope$2.invoke(TestCaseExecutor.kt)

4

0 に答える 0