Bartek Milken
10/22/2025, 1:06 PMIsolationMode.InstancePerLeaf?Bartek Milken
10/22/2025, 1:19 PMInstancePerLeaf , because we've developed methodology to resume Coroutines from mocks in following containers and test different outcomes for different resumed values.
Let's assume that there is repository that make some request with api. Tests for it would like this:
class RepoTest : CustomSpec({
val api: Api = mockk()
val requestContinuation = suspendContinuationFor { api.execute() }
val sut = Repo(
api = api,
)
"On request" - {
val result = scope.async { sut.request() }
"requests api" { coVerify(exactly = 1) { api.execute() } }
"On success" - {
requestContinuation.resume(Result.success(Unit))
"succeeds" { result.await() shouldBe Result.success(Unit) }
}
"On failure" - {
val exception = Exception("Network error")
requestContinuation.resume(Result.failure<Unit>(exception))
"fails" { result.await() shouldBe Result.failure<Unit>(exception) }
}
}
})
This test is basic, but methodology allowed us to complex cases, where previous steps in scenario were clearly visible. And there is just no way to achieve it with any other IsolationModeLukasz Kalnik
11/03/2025, 3:26 PMInstancePerLeaf in all our tests and miss it very much. It was useful for testing branching out of test cases, like e.g. different user reactions to the same dialog, different outcomes of a request etc.Richard Schielek
11/06/2025, 11:37 AMLukasz Kalnik
11/06/2025, 12:09 PMInstancePerLeaf and InstancePerTest, which were too hard to resolve.