How do you refactor Bluetooth code on Android with zero test coverage? When touching such code you have to test it with real phones and Bluetooth devices to ensure you are not breaking anything. Thus changes come with a high risk of introducing new bugs. At mySugr we spent quite some time refactoring our Bluetooth code, so that we can write plain Kotlin unit tests for it and easily add new functionality.
You are going to see how we achieved the refactoring with almost zero bugs and a minimal manual testing effort. This talk doesn’t deal with the details of Bluetooth on Android. Instead, we will discuss the strategies and methods we used and how it can be applied to any refactoring of dangerous code. Finally, I’m going to show you that you can even write tests for Bluetooth code - there is no excuse not to write tests.