From 091fc0fd091febe7c49e59ff87f0418f8c248db6 Mon Sep 17 00:00:00 2001 From: Paul Szczepanek Date: Tue, 26 Jan 2021 22:16:56 +0000 Subject: [PATCH 1/2] Add ble unit testing paragraph --- docs/api/connectivity/bluetooth/BLE.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/api/connectivity/bluetooth/BLE.md b/docs/api/connectivity/bluetooth/BLE.md index 8a607d3804..7cc029b51b 100644 --- a/docs/api/connectivity/bluetooth/BLE.md +++ b/docs/api/connectivity/bluetooth/BLE.md @@ -56,6 +56,20 @@ The class's member functions can be divided by purpose: [![View code](https://www.mbed.com/embed/?type=library)](https://os.mbed.com/docs/mbed-os/development/mbed-os-api-doxy/classble_1_1_b_l_e.html) +# BLE Unit Testing + +You may find it useful to add unit tests to your application or library. Mbed OS uses GoogleTest to provide a helpful framework of stubs and mocks to help you quickly write your unit tests. + +Please refer to the main [Unit Testing](../debug-test/unit-testing.html) page for details on how to use unit testing in Mbed OS. + +The BLE feature can be tested through a fake BLE instance which provides mocks. These will allow you to set expectations for your application's use of BLE APIs. + +Compiling the BLE.cpp from the [UNITTESTS/stubs](https://github.com/ARMmbed/mbed-os/tree/master/UNITTESTS/stubs) directory instead of the real BLE.cpp will allow you to create a BLE instance that uses mocks instead of real BLE modules. Including the special ble_mocks.h header you can gain access to these individual mocks. + +To setup your unit tests you can use the [BLE unit test template](https://github.com/ARMMbed/mbed-os/tree/ble-unittest/connectivity/FEATURE_BLE/tests/UNITTESTS/ble_template) as a starting point. + +It contains a cmake file with all the required paths and mock objects compiled. The test file itself contains all the headers and setup required to use the mock backed BLE instance. Just copy and add your tests. + ## Related content - Mbed Enabled [targets and components](https://os.mbed.com/platforms/?mbed-enabled=15&connectivity=3) that support BLE. From 0cd2b3c62ee458349969a87cced9bbaf7184b7d2 Mon Sep 17 00:00:00 2001 From: Paul Szczepanek Date: Wed, 27 Jan 2021 09:29:32 +0000 Subject: [PATCH 2/2] fix heading level --- docs/api/connectivity/bluetooth/BLE.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/api/connectivity/bluetooth/BLE.md b/docs/api/connectivity/bluetooth/BLE.md index 7cc029b51b..c10aa781b3 100644 --- a/docs/api/connectivity/bluetooth/BLE.md +++ b/docs/api/connectivity/bluetooth/BLE.md @@ -52,11 +52,7 @@ The class's member functions can be divided by purpose: 1. Construct a service class and add it to the BLE stack. 1. Push notifications when the characteristic's value changes. -## BLE class reference - -[![View code](https://www.mbed.com/embed/?type=library)](https://os.mbed.com/docs/mbed-os/development/mbed-os-api-doxy/classble_1_1_b_l_e.html) - -# BLE Unit Testing +## BLE Unit Testing You may find it useful to add unit tests to your application or library. Mbed OS uses GoogleTest to provide a helpful framework of stubs and mocks to help you quickly write your unit tests. @@ -70,6 +66,10 @@ To setup your unit tests you can use the [BLE unit test template](https://github It contains a cmake file with all the required paths and mock objects compiled. The test file itself contains all the headers and setup required to use the mock backed BLE instance. Just copy and add your tests. +## BLE class reference + +[![View code](https://www.mbed.com/embed/?type=library)](https://os.mbed.com/docs/mbed-os/development/mbed-os-api-doxy/classble_1_1_b_l_e.html) + ## Related content - Mbed Enabled [targets and components](https://os.mbed.com/platforms/?mbed-enabled=15&connectivity=3) that support BLE.