我正在尝试MockK BluetoothDevice
,但出现此错误:
java.lang.NoSuchMethodError: android.bluetooth.BluetoothDevice.getType()I
测试:
@MockK
private lateinit var bluetoothDevice: BluetoothDevice
@Before
fun start() {
MockKAnnotations.init(this, relaxUnitFun = true)
every { bluetoothDevice.type } returns 1
every { bluetoothDevice.getType() } returns 1
}
@Test
fun test() {
bluetoothDevice.type // error
}