I have several of Kotests in a 1.4.0 multi-platfor...
# kotest
s
I have several of Kotests in a 1.4.0 multi-platform project's jvmTest that used to work. I've changed a number of things so don't know what triggered this, but now they are all failing with the call stack below. Interestingly I think the tests are all running correctly before hitting this exception, because tests with println(..) calls in them are showing correctly on the console before this error hits. And if I introduce a failing shouldBe, I see that error like normal. So it's as if this is happening after each test is complete. All the test classes are StringSpec-based. Anyone else seen this? I'm using Kotlin 1.4.0, JUnit5 and Kotest 4.2.2 (also happens on 4.2.0). Also OpenJDK 14.0.2, but error also happens on JDK8 embedded with Android Studio, so I don't think it's a JDK thing.
Copy code
java.lang.IllegalArgumentException: wrong number of arguments
   at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
   at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
   at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
   at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
   at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
   at io.kotest.engine.InstantiateSpecKt.javaReflectNewInstance(instantiateSpec.kt:23)
   at io.kotest.engine.InstantiateSpecKt.instantiateSpec(instantiateSpec.kt:17)
   at io.kotest.engine.spec.SpecExecutor.createInstance(SpecExecutor.kt:101)
   at io.kotest.engine.spec.SpecExecutor.execute(SpecExecutor.kt:41)
   at io.kotest.engine.KotestEngine$submitBatch$$inlined$forEach$lambda$1$1.invokeSuspend(KotestEngine.kt:139)
   at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
   at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
   at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:274)
   at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:84)
   at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
   at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
   at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
   at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
   at io.kotest.engine.KotestEngine$submitBatch$$inlined$forEach$lambda$1.run(KotestEngine.kt:138)
   at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
   at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
   at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
   at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
   at java.base/java.lang.Thread.run(Thread.java:832)
Also these are all run using the gradle jvmTest task. Gradle is 6.6
s
Looks like you have a spec with a constructor that isn't zero-arg
s
Hmm. Ok here's what I did that used to be working that maybe is suspect. I have a bunch of StringSpecs that share some common behavior, so I made an abstract class TestBase(3 string args): StringSpec. All the tests I care about extend this TestBase and supply literals for the arguments. So those tests themselves have no extra arguments. Would having this intermediate abstract class between the tests and StringSpec cause the error?
I'm changing these all to use a helper class instead of extending the abstract class, will see if that fixes them
s
Set the intermediate to be abstract
s
It is. Or was, I've just about refactored it out of existence. Will know in a couple minutes if helper via composition fixes using abstract super class
Yup, that was it. The abstract super class is gone, and now all 20 tests are using the old abstract class as a concrete helper class , and all tests work. Thanks for helping, I would have never thought of this without your first response.
Something I did or changed broke these, the abstract intermediate class with primary constructor having arguments thing used to work. Doesn't matter, I be good now 🙂. Thanks again.
s
glad to hear