Bluetooth Roboletric返回空蓝牙管理器

Bluetooth Roboletric返回空蓝牙管理器,bluetooth,bluetooth-lowenergy,robolectric,Bluetooth,Bluetooth Lowenergy,Robolectric,我试着用Robolectric测试我使用蓝牙的应用程序。但是当我试图得到BluetoothManager时,我总是在Roboletric中得到空值 下面是我如何在Robolectric的课堂上尝试使用蓝牙管理器 final BluetoothManager bluetoothManager = (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE); 感觉好像我在机器人测角的设置中遗漏了一些简单的东西?以下是

我试着用Robolectric测试我使用蓝牙的应用程序。但是当我试图得到BluetoothManager时,我总是在Roboletric中得到空值

下面是我如何在Robolectric的课堂上尝试使用蓝牙管理器

final BluetoothManager bluetoothManager = (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
感觉好像我在机器人测角的设置中遗漏了一些简单的东西?以下是用于设置类的注释

@Config(
 sdk = Build.VERSION_CODES.KITKAT
 , manifest = "src\\main\\AndroidManifest.xml"
)
@RunWith(RobolectricTestRunner.class)

更新

如果使用Robolectric v3.1+

=========================

Robolectric提供了一个。但是,
BluetoothManager
不是它的一部分。我认为这是因为在API18之前,我们使用了
BluetoothAdapter.getDefaultAdapter()

看起来您的目标是最新的API,“旧”方式不是您的选择。作为测试的变通方法,您可以使用描述的方法


我还在Robolectric GitHub页面上创建了

这不再是事实。Robolectric已经支持Bluetooth Manager更新的答案。谢谢