From ba588757e6c577ce04b47a48eb84a99325831542 Mon Sep 17 00:00:00 2001 From: Davide Farella <4face91@protonmail.com> Date: Mon, 20 Sep 2021 16:36:42 +0200 Subject: [PATCH] Create 0005-use-run-blocking-test.md --- docs/0005-use-run-blocking-test.md | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 docs/0005-use-run-blocking-test.md diff --git a/docs/0005-use-run-blocking-test.md b/docs/0005-use-run-blocking-test.md new file mode 100644 index 000000000..977a7d13e --- /dev/null +++ b/docs/0005-use-run-blocking-test.md @@ -0,0 +1,33 @@ +# Use runBlockingTest + +* Status: Accepted +* Deciders: Marino, Zorica, Stefanija, Davide, Tomasz, Maciej +* Date: 10/09/2021 + + +## Context and Problem Statement + +Inconstancy in test between the usage of `runBlocking` and `runBlockingTest` + +## Considered Options +* `runBlocking` +* `runBlockingTest` + +#### Evaluations between `runBlocking` and `runBlockingTest` + +* Both of the solutions executes all the Coroutines on a single thread +* `runBlockingTest` is specifically **designed for test**, while `runBlocking` has a different purpose +* `runBlockingTest` enables us to control the **virtual time**, if needed +* `runBlockingTest` has auto-advance features, that let's us **skip the various `delay()`** and similar that would let the tests take a considerable amount of time to be completed +* `runBlockingTest` helps us to verify that the Coroutines has a **correct flow** ( e.g. does not "get stuck" or never completes ) and **does not leak** +* `runBlockingTest` has **some incompatibilities**, for example with Room's Transactions + +## Decision Outcome + +* We should use `runBlockingTest` as a standard +* We can use `runBlockingWithTimeout` when there is a incompatibility issue ( see Room's Transactions ) and the test cannot completes correctly otherwise + +## Consequences +1. We should replace `runBlocking` with `runBlockingTest` wherever possible +2. We should replace `runBlocking` with `runBlockingWithTimeout` when `runBlockingTest` cannot be used +3. Further discussion is needed for `coroutinesTest`