question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BleCharacteristicNotFoundException when mocking characteristic write with MockRxAndroidBle

See original GitHub issue

Summary

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:closed
  • Created 6 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
dariuszseweryncommented, Aug 30, 2017

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.

0reactions
dariuszseweryncommented, Sep 1, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found