reunu / unustasis

An open-source app for the Unu Scooter Pro
GNU General Public License v3.0
18 stars 4 forks source link

Refactored FlutterBluePlus into a mockable service in order to use bluetooth during testing #8

Closed dachrisch closed 3 months ago

dachrisch commented 3 months ago

The ScooterService now uses a mockable Service (with the same interface as the static service) so it is possible to write tests with programmatically added bluetooth devices. An example is given in [device_scanning_test.test] which uses custom builder to create bluetooth device mocks

TheFreal commented 3 months ago

Wait, so does this mean it's no longer possible to access FlutterBluePlus statically? Every use of FlutterBluePlus needs to share an instance of FlutterBluePlusMockable?

dachrisch commented 3 months ago

Wait, so does this mean it's no longer possible to access FlutterBluePlus statically? Every use of FlutterBluePlus needs to share an instance of FlutterBluePlusMockable?

That's the idea. In order to make it accessible in testing, this is the way. As all calls to this class should be encapsulated in ScooterService, there should be no problem