Closed s-hocking closed 4 years ago
What you may do, is to create peripheral specifications with proximity .outOfRange
, and then move them in or out of range for each test using
https://github.com/NordicSemiconductor/IOS-CoreBluetooth-Mock/blob/89e2e911b061ded12ed309d9745f27464299ed19/CoreBluetoothMock/Classes/CBMPeripheralSpec.swift#L189-L197
My assumption was that usually you have a single peripheral that your app is connecting to and performing different tests with it.
I will think about your feature request, but as far as I remember I did it for a purpose.
Also, I had to switch to another project for now and unfortunately have no idea when can I implement this feature.
But we will gladly accept a PR is you are willing to contribute!
My assumption was that usually you have a single peripheral that your app is connecting to and performing different tests with it.
That's definitely a big part of my tests! but another part is discovering and connecting to multiple devices with varying services / configuration. Your workaround of moving the peripherals in and out of range is a good idea.
I'd love to submit a PR for this - I'll see how I go for time.
Another use case to consider is the practicality of having multiple test files, with multiple setup phases. With the current mock framework, each test setup needs to attempt setting up the peripherals for all other test case files - which means that test cases are not well isolated from each other.
Resolved in 0.11.0 !
Hi there! I'm using this library to write automated tests for my BLE framework. It would be really helpful to be able to teardown the mock and add/remove simulated peripherals, and set it up again with a clean slate, to support automated testing. Is it possible to do this?
I should add that I have tried calling
simulatePowerOff()
as is done in the Example test cases, and then changing the simulated peripherals. But this prints the error "Warning: Peripherals can be added to simulation only once, and not after any central manager was initiated"