我正在尝试模拟测试蓝牙应用程序,但我创建一个BluetoothAdapter类的模拟对象的第一步是不工作!
我正在使用powermockito轻松模拟.
mBluetoothAdapter = (BluetoothAdapter)PowerMock.createMock(BluetoothAdapter.class);
这失败了.使用以下堆栈跟踪
java.lang.IllegalArgumentException: No visible constructors in class android.bluetooth.BluetoothAdapter
at org.easymock.internal.DefaultClassInstantiator.getConstructorToUse(DefaultClassInstantiator.java:94)
at org.easymock.internal.AndroidClassProxyFactory.createProxy(AndroidClassProxyFactory.java:48)
at org.easymock.internal.MocksControl.createMock(MocksControl.java:114)
at org.easymock.internal.MocksControl.createMock(MocksControl.java:88)
at org.easymock.internal.MocksControl.createMock(MocksControl.java:79)
at org.powermock.api.easymock.PowerMock.doCreateMock(PowerMock.java:2212)
at org.powermock.api.easymock.PowerMock.doMock(PowerMock.java:2163)
at org.powermock.api.easymock.PowerMock.createMock(PowerMock.java:89)
at com.xxx.blesimplesample.test.MainActivityTest.setUp(MainActivityTest.java:59)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1710)
任何人都使用任何模拟框架进行蓝牙应用程序模拟?任何建议都会有所帮助