When the test is executed with others, it passes successfully.
But in a standalone mode, two test cases fail:
`JvmLoggingFactory` should[jvm] > obtain a logging domain for[jvm] > a class with annotated package()[jvm] FAILED
io.kotest.assertions.AssertionFailedError: expected:<"OnPackage"> but was:<<empty string>>
`JvmLoggingFactory` should[jvm] > obtain a logging domain for[jvm] > a class in a nested non-annotated package()[jvm] FAILED
io.kotest.assertions.AssertionFailedError: expected:<"OnPackage"> but was:<<empty string>>
The reason is in a lazy initialized annotatedPackages property that lives is LoggingDomainClassValue.kt. It grasps (once!) all packages that are annotated with the logging domain annotation and uses them for searching. But it looks like not all of them go there from the very beginning.
Workaround
Add an initialization block to JvmLoggingFactorySpec that triggers loading of the lacking packages in advance.
internal class JvmLoggingFactorySpec {
init {
// Triggers loading of Java packages to the runtime classpath in advance.
// Thus, correctly initializing lazy `LoggingDomainClassValue.annotatedPackages` property.
IndirectlyAnnotatedClass::class.simpleName shouldBe "IndirectlyAnnotatedClass"
}
...
}
When the test is executed with others, it passes successfully.
But in a standalone mode, two test cases fail:
The used command:
The reason is in a lazy initialized
annotatedPackages
property that lives isLoggingDomainClassValue.kt
. It grasps (once!) all packages that are annotated with the logging domain annotation and uses them for searching. But it looks like not all of them go there from the very beginning.Workaround
Add an initialization block to
JvmLoggingFactorySpec
that triggers loading of the lacking packages in advance.