-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support multiple Kotest spec instances #860
Conversation
@@ -51,6 +51,7 @@ object MicronautKotest5Extension: TestListener, ConstructorExtension, TestCaseEx | |||
|
|||
override suspend fun afterSpec(spec: Spec) { | |||
contexts[spec.javaClass.name]?.afterSpecClass(spec) | |||
contexts[spec.javaClass.name]?.close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line above already closes the application context here:
So this addition doesn't really do anything at the moment.
@@ -116,4 +116,7 @@ class MicronautKotest5Context( | |||
) | |||
} | |||
|
|||
fun close() { | |||
applicationContext.close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This throws NPE now, the applicationContext
is stopped and nullified by afterSpecClass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this isn't the fix, but I know what is now.
I'll update it and add a test.
I think this should do it @Spikhalskiy |
@sksamuel I confirm that with this change the issue I reported in kotest/kotest#3711 is resolved, all initialized contexts in the sample project are getting shutdown. |
test-kotest5/src/main/kotlin/io/micronaut/test/extensions/kotest5/MicronautKotest5Extension.kt
Outdated
Show resolved
Hide resolved
@dstepanov Anything we can do to advance this PR? |
Looks fine to me |
Hi Micronaut folks!
I think the application context should be closed when a Kotest spec finishes executing, otherwise the resources are not cleaned up.Kotest5Context needs to support multiple instances of specs.
See bug report here: kotest/kotest#3711