https://kotlinlang.org logo
#kotest
Title
# kotest
r

Rob Elliot

11/24/2021, 4:39 PM
Just added
kotest-extensions-spring:1.0.1
to my maven project (using surefire to run
kotest-framework-api-jvm:4.6.3
) and with no code changes it stopped finding any of my existing specs. No errors logged, it just silently stops working.
Using
KOTEST_DEBUG=true
as an env var the end of the maven run looks like this:
Copy code
Discovery: Loading specified classes...
Discovery: Loading of selected classes completed in 0ms
After filters there are 3 spec classes
JUnit ExecutionRequest[org.junit.platform.engine.ExecutionRequest] [configurationParameters=LauncherConfigurationParameters [lookups = [systemProperties [...], propertiesFile []]]; rootTestDescriptor=KotestEngineDescriptor: [engine:kotest]]
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  23.442 s
[INFO] Finished at: 2021-11-24T16:32:34Z
[INFO] ------------------------------------------------------------------------
s

sam

11/24/2021, 4:40 PM
you literally just changed the pom ?
r

Rob Elliot

11/24/2021, 4:40 PM
Yes
Running in IntelliJ via the plugin IntelliJ reports
Test framework quit unexpectedly
, but again no further information.
s

sam

11/24/2021, 4:41 PM
It adds a ConstructorExtension which is automatically used to construct classes
I guess if that had some kind of error
I can see why this is failing on 4.6.3 and fix that as 4.6.4 but it will come after thanks giving
r

Rob Elliot

11/24/2021, 4:43 PM
OK, thanks - is there an earlier version of kotest and/or the extension you’d expect to work?
s

sam

11/24/2021, 4:44 PM
that extension is used quite heavily, most of any extensions
so you probably have some class lurking about that it can't handle, and kotest isn't catching the exception properly is my guess
are you upgrading to kotlin 1.6 at all ?
r

Rob Elliot

11/24/2021, 4:45 PM
No, on 1.5.31 at the moment
s

sam

11/24/2021, 4:45 PM
ok so you can't use kotest 5
r

Rob Elliot

11/24/2021, 4:45 PM
I’ll try debugging in
SpringAutowireConstructorExtension
and see if I can work out where the issue us.
s

sam

11/24/2021, 4:45 PM
ok, in the meantime I'll add a test that deliberately fails a constructor extension to make sure the error is correctly reported
I need to go offline in an hour to drive to IA for thanksgiving, but I can investigate until then
r

Rob Elliot

11/24/2021, 4:47 PM
I’m not paying you, don’t stress it! If I can work it out I’ll raise a PR.
😂 1
s

sam

11/24/2021, 4:47 PM
what can I say, I take my work and non-work seriously haha
👍 1
Ok 5.0 does the right thing, and reports exceptions
r

Rob Elliot

11/24/2021, 5:59 PM
I understand why the error isn’t being reported -
KoTestEngine.execute
does
Try { submitAll(plan) }
, but
fun submitAll(plan: TestPlan) = Try { ... }
, so you get a nested
Try<Try<>>
where the top one is a
Success
but the nested one is a
Failure
, so the error reporting
fold
doesn’t get triggered.
s

sam

11/24/2021, 5:59 PM
Ah
That's 4.6 specific
If you wanna raise a pr we can deploy
r

Rob Elliot

11/24/2021, 6:00 PM
I’ll have a go.
The problem it’s failing to report though is really bizarre -
java.lang.NoSuchMethodError: 'void io.kotest.mpp.LoggerKt.log(java.lang.String)'
But I can see that method! It’s on the classpath! And anyway, why would
kotest-extensions-spring
being on the classpath make it happen?!
s

sam

11/24/2021, 6:07 PM
Hmm that's a multiplatform thing
Maybe spring uses it
And maven gets confused
r

Rob Elliot

11/24/2021, 6:11 PM
Yup,
kotest-extensions-spring
depends on
io.kotest:kotest-framework-engine-jvm:4.4.3
.
That’ll be it.
s

sam

11/24/2021, 6:11 PM
Ahh
We can bump that and deploy 1 0.2
I'll do that in a minute
r

Rob Elliot

11/24/2021, 6:12 PM
Is there a kotest bom I can use to try and prevent accidental dependency reversion?
s

sam

11/24/2021, 6:12 PM
Yep
r

Rob Elliot

11/24/2021, 6:13 PM
Awesome, that’ll fix it. Thanks for your help.
s

sam

11/24/2021, 6:13 PM
No thank you I didn't do anything lol
Ok just checked the spring extension and it doesn't use log at all, so yeah it's just the version getting changed by bringing it in. Nice find.
r

Rob Elliot

11/24/2021, 6:17 PM
Unfortunately the bom doesn’t declare the
kotest-*-jvm
artifacts - joys of being on Maven not Gradle.
s

sam

11/24/2021, 6:20 PM
You could just add that to your build explicitly
r

Rob Elliot

11/24/2021, 6:20 PM
Yup, that’s what I’m doing
3 Views