CloseableLifecycleConformanceSuite
Reusable lifecycle contract test suite for ScopedCloseable implementations.
Subclass and implement create to bind any coordinator under test. The returned instance must be freshly constructed (owning its own child job) and must not be closed yet.
Lives in commonMain of :kuilt-conformance so every module can subclass it from its own commonTest source set. Every Test encodes a required invariant of the ScopedCloseable contract — a conforming implementation must pass all of them.
Test-body close requirement. Every test that creates a coordinator must call AutoCloseable.close before the test body exits (or use use {}). An un-closed coordinator with a live anti-entropy loop can freeze virtual time in runTest (kotlinx.coroutines.test.UncompletedCoroutinesError).
Wiring
class MyCoordinatorLifecycleTest : CloseableLifecycleConformanceSuite() {
override fun create(scope: CoroutineScope): MyCoordinator =
MyCoordinator(scope)
override fun backgroundJobsOf(instance: ScopedCloseable): List<Job> =
(instance as MyCoordinator).backgroundJobsForTest
}