Open Xaseron opened 2 years ago
I have found the cause, but i don't really understand it. The tests are only working when the ApplicationContext is defined inside the TestContext.
Working test:
class DemoCommandStringTest : StringSpec() {
init {
"Hi!" {
val ctx = ApplicationContext.run(Environment.CLI, Environment.TEST)
val baos = ByteArrayOutputStream()
System.setOut(PrintStream(baos))
val args = arrayOf("-v")
PicocliRunner.run(DemoCommand::class.java, ctx, *args)
baos.toString() shouldContain "Hi!"
ctx.close()
}
}
}
Expected Behavior
Simple StringSpec should work:
Actual Behaviour
Steps To Reproduce
My test worked with Micronaut 3.5.5. But after updating to Micronaut 3.6.3 StringSpec tests with above described setup are failing. The strange thing is that other test variants like Behavior Specs are not affected. StringSpec: https://github.com/Xaseron/bugreport/blob/master/src/test/kotlin/com/example/DemoCommandStringTest.kt DescribeSpec: https://github.com/Xaseron/bugreport/blob/master/src/test/kotlin/com/example/DemoCommandBehaviorTest.kt
Both test do exactly the same but StringSpec is not working anymore with Micronaut 3.6.x
Environment Information
JDK: 17 Micronaut: 3.6.0 and newer
Example Application
https://github.com/Xaseron/bugreport
Version
3.6.3