Warmup molecule only once.

This commit is contained in:
Marco Romano 2023-09-13 15:42:48 +02:00
parent b860bd30bd
commit 5d8666a507

View file

@ -33,8 +33,16 @@ import kotlin.time.Duration.Companion.seconds
* 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 {
warmUpMolecule()
}
}
override fun apply(base: Statement, description: Description): Statement = base
}
private fun warmUpMolecule() {
runTest(timeout = 60.seconds) { runTest(timeout = 60.seconds) {
moleculeFlow(RecompositionMode.Immediate) { moleculeFlow(RecompositionMode.Immediate) {
// Do nothing // Do nothing
@ -42,7 +50,4 @@ class WarmUpRule: TestRule {
awaitItem() // Await a Unit composition awaitItem() // Await a Unit composition
} }
} }
base.evaluate()
}
}
} }