-
Notifications
You must be signed in to change notification settings - Fork 589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove need to use RoboElectric for creating tests using MockRxAndroidBle
#311
Comments
Unfortunately, I agree :) The current implementation is not the best. Let's leave this issue open as an entry point to mock redesign. |
Actually mock was not written with unit testing in mind. It's purpose is to allow working on Bluetooth stuff without having the actual device, but I agree that it could be better and making it work in unit tests would be great :) |
This issue is a part of #213 and #239. The new API aims for fully wrapping the Android OS objects. I am also thinking if there is really a need for the It could be put up for a discussion if we should remove this part of
|
I'd keep it as it is possible to use it in unit tests. Certainly, it would be helpful if the framework would have some mocking/assertion engine. For example |
I think that this kind of a test would effectively test the |
I entered this test-enhancement, the removal of the need of RoboElectric, since we have a bunch end-to-end tests written as unit-tests (no need to start them on a device). In these tests, the Thank you all for looking into this! |
I think this should be closed in favor of #370. Feel free to reopen if you think otherwise. |
Summary
Remove the need for RoboElectric when writing tests using
MockRxAndroidBle
RoboElectric causes the startup of tests to be quite slow. Removing the dependency
on RoboElectric and being able to use only Mockito, for example, would improve the
process of TDD because tests can be run faster.
Library version
1.4.1
Issue found in
MockRxAndroidBle
implementationWhen trying to run tests that use the
MockRxAndroidBle
class without RoboElectric, they fail because the test-code creates instances of classes from the Android SDK.Our test-suite reports failures of usages of these classes:
BluetoothGattService
BluetoothGattCharacteristic
BluetoothGattDescriptor
Using PowerMock and using it to create mock-instances of these three classes makes these failures go away and the tests in our own project run fine!
However, using PowerMock requires this annotation at the head of the test-suite-class:
(snippet in Kotlin)
Needless to say, this annotation is given knowledge of internal and private implementation details of
MockRxAndroidBle
. There's no guarantee that a future version of `MockRxAndroidBle' won't break this annotation configuration.....Request for change in
MockRxAndroidBle
implementation.Currently (version 1.4.1), the
RxBleClientMock.CharacteristicsBuilder
,RxBleClientMock.DeviceBuilder
andRxBleConnectionMock$21
(anonymous class) create instance ofBluetoothGattService
,BluetoothGattCharacteristic
orBluetoothGattDescriptor
directly.MockRxAndroidBle
could create mocked version instead (and thereby requiring only Mockito).The text was updated successfully, but these errors were encountered: