package Ġcom . cook pad . pure e . kotlin . rule Ċ Ċ import Ġandroidx . lifecycle . Lifecycle Ċ import Ġandroidx . lifecycle . testing . Test Lifecycle Owner Ċ import Ġkotlinx . coroutines . Dispatch ers Ċ import Ġkotlinx . coroutines . Experimental Cor outines Api Ċ import Ġkotlinx . coroutines . test . Test Coroutine Dispatcher Ċ import Ġorg . junit . rules . Test Watcher Ċ import Ġorg . junit . runner . Description Ċ Ċ @ Opt In ( Experimental Cor outines Api :: class ) Ċ class ĠLifecycle Coroutine Rule Ġ: ĠTest Watcher () Ġ{ ĊĠĠĠ Ġlateinit Ġvar Ġcoroutine Dispatcher : ĠTest Coroutine Dispatcher ĊĠĠĠĠĠĠĠ Ġprivate Ġset ĊĠĠĠ Ġlateinit Ġvar Ġlifecycle Owner : ĠTest Lifecycle Owner ĊĠĠĠĠĠĠĠ Ġprivate Ġset ĊĊĠĠĠ Ġoverride Ġfun Ġstarting ( description : ĠDescription ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . starting ( description ) ĊĠĠĠĠĠĠĠ Ġcoroutine Dispatcher Ġ= ĠTest Coroutine Dispatcher () ĊĠĠĠĠĠĠĠ Ġlifecycle Owner Ġ= ĠTest Lifecycle Owner ( Lifecycle . State . STARTED ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġfinished ( description : ĠDescription ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . finished ( description ) ĊĠĠĠĠĠĠĠ Ġlifecycle Owner . handle Lifecycle Event ( Lifecycle . Event . ON _ STOP ) ĊĠĠĠĠĠĠĠ Ġcoroutine Dispatcher . cleanup Test Cor outines () ĊĠĠĠ Ġ} Ċ } Ċ