This PR addresses GitHub issue #9909 by implementing a comprehensive test suite for ZIOApp behavior validation. The test suite ensures that ZIO applications behave correctly during normal completion, failure scenarios, and external signal interruption across all supported platforms.
ZIOAppBehaviorSpec - Main test suite for JVM/Native platforms with 9 comprehensive test casesZIOAppBehaviorJSSpec - JavaScript-specific tests adapted for browser environment limitationsZIOAppBehaviorNativeSpec - Scala Native-specific tests with platform-appropriate behavior validationTestableZIOApp - Base class extending ZIOAppDefault with testing capabilitiesTestResult - Comprehensive result capture without process terminationZIOAppSpec tests continue to pass β
scalafmt β
core-tests/jvm-native/src/test/scala/zio/ZIOAppBehaviorSpec.scala (245 lines)
core-tests/js/src/test/scala/zio/ZIOAppBehaviorJSSpec.scala (180 lines)
core-tests/native/src/test/scala/zio/ZIOAppBehaviorNativeSpec.scala (165 lines)
docs/ZIOAppBehaviorTests.md (223 lines)
ZIOAppDefault for realistic behavior without affecting actual runtimeAtomicBoolean flags and ZIO.whileLoop to ensure proper timing between resource acquisition and interruptionTestResult captures all relevant execution information without process terminationabstract class TestableZIOApp extends ZIOAppDefault {
val finalizerRan = new AtomicBoolean(false)
val resourceAcquired = new AtomicBoolean(false)
def runTest(): UIO[TestResult]
def runTestWithInterruption(): UIO[TestResult] // Waits for resource acquisition
}
The original issue requested comprehensive tests for ZIOApp behavior. This implementation provides:
# Run all ZIOApp behavior tests
sbt "coreTestsJVM/testOnly zio.ZIOAppBehaviorSpec"
# Run platform-specific tests
sbt "coreTestsJS/testOnly zio.ZIOAppBehaviorJSSpec"
sbt "coreTestsNative/testOnly zio.ZIOAppBehaviorNativeSpec"
# Run specific test suites
sbt "coreTestsJVM/testOnly zio.ZIOAppBehaviorSpec -- -t \"App Completion\""
scalafmt to ensure code follows ZIO project standardsCloses #9909
Related: #9901, #9807, #9240
/claim #9909
Vishwanath Martur
@vishwamartur
ZIO
@ZIO