:wave: Is there a way to solve this error when run...
# kotest
e
👋 Is there a way to solve this error when running a single test on Android Studio?
MyViewModelTest has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0
s
You're using an older version of the jdk
e
I’m using OpenJDK 17.0.8. Which version should I use?
s
This isn't a kotest thing. But 61 is java 17. You seem to have java 8 somewhere
e
If I run the tests by pressing the play button in the class, it works perfectly however, doing the same in an individual test, it raises that error.
s
Class Play button uses gradle
Individual from the ide settings
e
Do you know which setting it takes into account for this?
s
Not off the top of my head
👌 1
m
It may help to have a look at the configuration and its template
e
Sorry @Mervyn McCreight I haven’t understood that. 🙏
Even though I’m still not able to run individual tests, I advanced a little bit with this issue. In the Run/Debug Configurations dialog, if I choose Java 17, when I run the test, it now throws another error:
Copy code
java.lang.NoClassDefFoundError: kotlin/reflect/full/KClasses
	at io.kotest.mpp.JvmReflection.annotations(reflection.kt:35)
	at io.kotest.mpp.JvmReflection.annotations(reflection.kt:26)
	at io.kotest.engine.concurrency.ConcurrencyKt.isIsolate(concurrency.kt:22)
	at io.kotest.engine.ConcurrentTestSuiteScheduler.schedule(ConcurrentTestSuiteScheduler.kt:41)
	at io.kotest.engine.TestEngine$execute$innerExecute$1.invokeSuspend(TestEngine.kt:65)
	at io.kotest.engine.TestEngine$execute$innerExecute$1.invoke(TestEngine.kt)
	at io.kotest.engine.TestEngine$execute$innerExecute$1.invoke(TestEngine.kt)
	at io.kotest.engine.interceptors.TestEngineInitializedInterceptor.intercept(TestEngineInitializedInterceptor.kt:16)
	at io.kotest.engine.TestEngine$execute$execute$1$1.invokeSuspend(TestEngine.kt:71)
	at io.kotest.engine.TestEngine$execute$execute$1$1.invoke(TestEngine.kt)
	at io.kotest.engine.TestEngine$execute$execute$1$1.invoke(TestEngine.kt)
	at io.kotest.engine.interceptors.DumpConfigInterceptor.intercept(DumpConfigInterceptor.kt:21)
	at io.kotest.engine.TestEngine$execute$execute$1$1.invokeSuspend(TestEngine.kt:71)
	at io.kotest.engine.TestEngine$execute$execute$1$1.invoke(TestEngine.kt)
	at io.kotest.engine.TestEngine$execute$execute$1$1.invoke(TestEngine.kt)
	at io.kotest.engine.interceptors.WriteFailuresInterceptor.intercept(WriteFailuresInterceptor.kt:34)
	at io.kotest.engine.TestEngine$execute$execute$1$1.invokeSuspend(TestEngine.kt:71)
	at io.kotest.engine.TestEngine$execute$execute$1$1.invoke(TestEngine.kt)
	at io.kotest.engine.TestEngine$execute$execute$1$1.invoke(TestEngine.kt)
	at io.kotest.engine.interceptors.EmptyTestSuiteInterceptor.intercept(EmptyTestSuiteInterceptor.kt:27)
	at io.kotest.engine.TestEngine$execute$execute$1$1.invokeSuspend(TestEngine.kt:71)
	at io.kotest.engine.TestEngine$execute$execute$1$1.invoke(TestEngine.kt)
	at io.kotest.engine.TestEngine$execute$execute$1$1.invoke(TestEngine.kt)
	at io.kotest.engine.interceptors.ProjectTimeoutEngineInterceptor.intercept(ProjectTimeoutEngineInterceptor.kt:15)
	at io.kotest.engine.TestEngine$execute$execute$1$1.invokeSuspend(TestEngine.kt:71)
	at io.kotest.engine.TestEngine$execute$execute$1$1.invoke(TestEngine.kt)
	at io.kotest.engine.TestEngine$execute$execute$1$1.invoke(TestEngine.kt)
	at io.kotest.engine.interceptors.ProjectListenerEngineInterceptor.intercept(ProjectListenerEngineInterceptor.kt:23)
	at io.kotest.engine.TestEngine$execute$execute$1$1.invokeSuspend(TestEngine.kt:71)
	at io.kotest.engine.TestEngine$execute$execute$1$1.invoke(TestEngine.kt)
	at io.kotest.engine.TestEngine$execute$execute$1$1.invoke(TestEngine.kt)
	at io.kotest.engine.interceptors.ProjectExtensionEngineInterceptor$intercept$initial$1.invokeSuspend(ProjectExtensionEngineInterceptor.kt:22)
	at io.kotest.engine.interceptors.ProjectExtensionEngineInterceptor$intercept$initial$1.invoke(ProjectExtensionEngineInterceptor.kt)
	at io.kotest.engine.interceptors.ProjectExtensionEngineInterceptor$intercept$initial$1.invoke(ProjectExtensionEngineInterceptor.kt)
	at io.kotest.engine.interceptors.ProjectExtensionEngineInterceptor.intercept(ProjectExtensionEngineInterceptor.kt:34)
	at io.kotest.engine.TestEngine$execute$execute$1$1.invokeSuspend(TestEngine.kt:71)
	at io.kotest.engine.TestEngine$execute$execute$1$1.invoke(TestEngine.kt)
	at io.kotest.engine.TestEngine$execute$execute$1$1.invoke(TestEngine.kt)
	at io.kotest.engine.interceptors.SpecSortEngineInterceptor.intercept(SpecSortEngineInterceptor.kt:29)
	at io.kotest.engine.TestEngine$execute$execute$1$1.invokeSuspend(TestEngine.kt:71)
	at io.kotest.engine.TestEngine$execute$execute$1$1.invoke(TestEngine.kt)
	at io.kotest.engine.TestEngine$execute$execute$1$1.invoke(TestEngine.kt)
	at io.kotest.engine.interceptors.TestDslStateInterceptor.intercept(TestDslStateInterceptor.kt:15)
	at io.kotest.engine.TestEngine$execute$execute$1$1.invokeSuspend(TestEngine.kt:71)
	at io.kotest.engine.TestEngine$execute$execute$1$1.invoke(TestEngine.kt)
	at io.kotest.engine.TestEngine$execute$execute$1$1.invoke(TestEngine.kt)
	at io.kotest.engine.interceptors.TestEngineStartedFinishedInterceptor.intercept(TestEngineStartedFinishedInterceptor.kt:22)
	at io.kotest.engine.TestEngine$execute$execute$1$1.invokeSuspend(TestEngine.kt:71)
	at io.kotest.engine.TestEngine$execute$execute$1$1.invoke(TestEngine.kt)
	at io.kotest.engine.TestEngine$execute$execute$1$1.invoke(TestEngine.kt)
	at io.kotest.engine.TestEngine.execute$kotest_framework_engine(TestEngine.kt:77)
	at io.kotest.engine.TestEngineLauncher.async(TestEngineLauncher.kt:244)
	at io.kotest.engine.launcher.MainKt$main$1.invokeSuspend(main.kt:36)
	at io.kotest.engine.launcher.MainKt$main$1.invoke(main.kt)
	at io.kotest.engine.launcher.MainKt$main$1.invoke(main.kt)
	at io.kotest.common.RunBlockingKt$runBlocking$1.invokeSuspend(runBlocking.kt:3)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
	at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:277)
	at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:95)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:69)
	at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:48)
	at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
	at io.kotest.common.RunBlockingKt.runBlocking(runBlocking.kt:3)
	at io.kotest.engine.launcher.MainKt.main(main.kt:34)
Caused by: java.lang.ClassNotFoundException: kotlin.reflect.full.KClasses
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
	... 66 more

kotlin/reflect/full/KClasses
I advanced a little bit with this issue: adding this dependency
testImplementation(kotlin("reflect"))
makes the single test raise this new error:
Copy code
mo.ntc.picking.android.app.home.domain.models.AreaDetail
java.lang.ClassNotFoundException: mo.ntc.picking.android.app.home.domain.models.AreaDetail
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
	at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
	at mo.ntc.picking.android.app.home.domain.AreaDetailMother.ambient(AreaDetailMother.kt:7)
	at mo.ntc.picking.android.app.home.presentation.screens.areadetail.AreaDetailViewModelTest$1$2.invokeSuspend(AreaDetailViewModelTest.kt:51)
	at mo.ntc.picking.android.app.home.presentation.screens.areadetail.AreaDetailViewModelTest$1$2.invoke(AreaDetailViewModelTest.kt)
	at mo.ntc.picking.android.app.home.presentation.screens.areadetail.AreaDetailViewModelTest$1$2.invoke(AreaDetailViewModelTest.kt)
	at io.kotest.core.spec.style.scopes.DescribeSpecRootScope$context$1.invokeSuspend(DescribeSpecRootScope.kt:26)
	at io.kotest.core.spec.style.scopes.DescribeSpecRootScope$context$1.invoke(DescribeSpecRootScope.kt)
	at io.kotest.core.spec.style.scopes.DescribeSpecRootScope$context$1.invoke(DescribeSpecRootScope.kt)
	...