From 67e2255d985b8294d5e98787412e428cb96d4ead Mon Sep 17 00:00:00 2001 From: Daniel Frett Date: Fri, 20 Dec 2024 14:18:02 -0700 Subject: [PATCH] adjust AccordionSectionControllerTest to initialize TestLifecycleOwner after the main dispatcher is set --- .../AccordionSectionControllerTest.kt | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/ui/base-tool/src/test/kotlin/org/cru/godtools/base/tool/ui/controller/AccordionSectionControllerTest.kt b/ui/base-tool/src/test/kotlin/org/cru/godtools/base/tool/ui/controller/AccordionSectionControllerTest.kt index 02e2dcb2b5..2218790179 100644 --- a/ui/base-tool/src/test/kotlin/org/cru/godtools/base/tool/ui/controller/AccordionSectionControllerTest.kt +++ b/ui/base-tool/src/test/kotlin/org/cru/godtools/base/tool/ui/controller/AccordionSectionControllerTest.kt @@ -38,17 +38,19 @@ class AccordionSectionControllerTest { @get:Rule val instantTaskExecutorRule = InstantTaskExecutorRule() - private val baseLifecycleOwner = TestLifecycleOwner() - private val eventBus = mockk(relaxUnitFun = true) - private val accordionController = AccordionController( - mockkToolContentAccordionBinding(), - mockk { - every { eventBus } returns this@AccordionSectionControllerTest.eventBus - every { lifecycleOwner } returns baseLifecycleOwner - every { toolState } returns State() - }, - mockk() - ) + private val baseLifecycleOwner by lazy { TestLifecycleOwner() } + private val eventBus: EventBus = mockk(relaxUnitFun = true) + private val accordionController by lazy { + AccordionController( + mockkToolContentAccordionBinding(), + mockk { + every { eventBus } returns this@AccordionSectionControllerTest.eventBus + every { lifecycleOwner } returns baseLifecycleOwner + every { toolState } returns State() + }, + mockk() + ) + } private lateinit var controller: AccordionController.SectionController