TestResilientScope
A ResilientScope factory for testing.
Use this in unit tests to create resilient policies without needing a real application scope. The returned ResilientScope can be closed to cancel all policies and operations.
Example:
@Test
fun `test retry policy`() = runTest {
val testScope = TestResilientScope()
val policy = resilient(testScope) {
retry { maxAttempts = 3 }
}
// ... test logic
testScope.close() // cleanup
}Content copied to clipboard
Return
A ResilientScope instance for testing.
Parameters
dispatcher
The CoroutineDispatcher for the scope. Defaults to Dispatchers.Default.