Mario Adam
07/12/2023, 2:26 PMclass Connector() {
val scanObservers = mutableListOf<(Scan) -> Unit>()
}
and
class ScanProcessorViewModel constructor(connector: Connector) {
init {
connector.scanObservers.add {
someMethod()
}
}
}
I have started a unit test including following properties:
@RelaxedMockK
lateinit var connector: Connector
@SpyK
@InjectMockKs
lateinit var viewModel: ScanProcessorViewModel
How can I mock the scanObservers
property and then verify that an entry has been added by the init
block?Sam
07/12/2023, 2:33 PMMario Adam
07/12/2023, 3:10 PMconnector
able to be a concrete instance instead of a mock while the other stuff remains mocked.Mario Adam
07/12/2023, 3:14 PMconnector
as well, as this class has an init
block as well which does some concrete system calls (precisely: broadcasting intents)