BleCharacteristicNotFoundException when mocking characteristic write with MockRxAndroidBle
See original GitHub issueSummary
I posted this issue to StackOverflow but haven’t received any responses. There are more details there, but the main issue is that an exception is being thrown when attempting to write to a characteristic using MockRxAndroidBle.
Example code that reproduces this issue can be found in this gist
Library version
1.3.2, 1.3.3
Actual result
BleCharacteristicNotFoundException is thrown.
Expected result
The write operation is mocked successfully.
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Mocking BLE Characteristic Write with MockRxAndroidBle
I'm writing a JUnit test for writing data to a BLE characteristic using the MockRxAndroidBle. The characteristics are being added to the mock...
Read more >BleCharacteristicNotFoundExcep...
I am unable to retrieve data from my device despite supplying what I believe to be the correct UUID: D/ERROR:: ...
Read more >Unit Testing Android BLE Code with RxAndroidBle
A mocked RxBleClient allows us to directly control behaviors like scanning and connecting while writing unit tests. RxBleDeviceMock: An instance ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Unfortunately it is not possible to solve without fully wrapping the Android API in the library. Currently the Android API is visible in the Library API — we have started internal discussion on wether / how to fully enclose the Android API.
The Mock Library was initially (at least by me) considered to be a drop-in replacement for in-app usage — not for using in tests but @uKL has memories that suggest it should work also in the tests.
Bottom line — in the current state the Mock Library will not work correctly if the Android sources are not available. A potential workaround is to use
Robolectric
in the tests. We are considering an API that will fully enclose the Android API and would make it possible to use the Mock Library virtually everywhere.I agree - this is misleading. We will add the note and we are evaluating an idea to enhance the new API proposition #239 to wrap the Android API fully - it would allow to use the mock library in the unit tests without the need of
Robolectric
.