我只是不明白为什么我在scan()中的存根方法scanBleDevices()会返回模拟对象。
蓝牙适配器:
fun scan(scanTimeoutMillis: Long): Flowable<Packet> = bluetoothClient
.scanBleDevices(ScanSettings.Builder()
.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).build())....
测试:
val spyBleAdapter = Mockito.spy(viewModel.scanBluetoothFlowabler.bluetoothAdapter)
viewModel.scanBluetoothFlowabler.bluetoothAdapter = spyBleAdapter
val spyBleClient = Mockito.spy(spyBleAdapter.bluetoothClient)
spyBleAdapter.bluetoothClient = spyBleClient
whenever(spyBleClient.scanBleDevices(fakeScanSettings))
.thenReturn(Observable.just(mockScanResult))
// here it returns mockScanResult
val scanBleDevices = spyBleClient.scanBleDevices(fakeScanSettings)
// scanBleDevices() inside scan() is not stubbed so i got not implemented exception
val scan = spyBleAdapter.scan(ArgumentMatchers.anyLong())
我在做什么错了?