Warmup molecule only once.
This commit is contained in:
parent
b860bd30bd
commit
5d8666a507
1 changed files with 16 additions and 11 deletions
|
|
@ -32,17 +32,22 @@ import kotlin.time.Duration.Companion.seconds
|
||||||
* Applying this test rule ensures that the slow initialisation is not done
|
* Applying this test rule ensures that the slow initialisation is not done
|
||||||
* inside runTest which has a short default timeout.
|
* inside runTest which has a short default timeout.
|
||||||
*/
|
*/
|
||||||
class WarmUpRule: TestRule {
|
class WarmUpRule : TestRule {
|
||||||
override fun apply(base: Statement, description: Description): Statement = object: Statement() {
|
companion object {
|
||||||
override fun evaluate() {
|
init {
|
||||||
runTest(timeout = 60.seconds) {
|
warmUpMolecule()
|
||||||
moleculeFlow(RecompositionMode.Immediate) {
|
}
|
||||||
// Do nothing
|
}
|
||||||
}.test {
|
|
||||||
awaitItem() // Await a Unit composition
|
override fun apply(base: Statement, description: Description): Statement = base
|
||||||
}
|
}
|
||||||
}
|
|
||||||
base.evaluate()
|
private fun warmUpMolecule() {
|
||||||
|
runTest(timeout = 60.seconds) {
|
||||||
|
moleculeFlow(RecompositionMode.Immediate) {
|
||||||
|
// Do nothing
|
||||||
|
}.test {
|
||||||
|
awaitItem() // Await a Unit composition
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue