如何模拟蓝牙设备

时间:2019-05-31 15:50:31

标签: android kotlin bluetooth mockk

我正在尝试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
}

0 个答案:

没有答案