Unit/integration tests for Bluetooth Low Energy Application
-
Hi,
I have developed a GUI Application for connecting to Bluetooth Low Energy devices and saving the data which comes from the sensor. Now I would like to create automated Unit tests (with QTest) to ensure that every unit works fine.
So, e.g. I have a a class, which has the following functions, Signals for scanning for and connecting to Bluetooth Low Energy Devices (The following functions do not contain any code, it is only meant to be illustrative)
void BluetoothModel::startDeviceDiscovery() { /*Available Sots: deviceDiscoveredSot , deviceDiscoveryFinishedSlot*/ } void BluetoothModel::deviceDiscoveredSlot(const QBluetoothDeviceInfo &device) { if(device.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration) { emit deviceDiscoveredSignal(device); } } void BluetoothModel::deviceDiscoveryFinishedSot() { emit deviceDiscovereyFinished(); } /*connects to device*/ void BluetoothModel::connectToDevice(QBluetoothDeviceInfo device) { /*Available Slots: startServiceDiscoverySlot*/ } void BluetoothModel::startServiceDiscoverySlot() { /*Available Sots: serviceDiscoveryFinishedSlot*/ } void BluetoothModel::serviceDiscoveryFinishedSlot() { emit serviceDiscoveryFinishedSignal(); } void BluetoothModel::startServiceDetailsDiscovery(QBluetoothUuid serviceUuid) { /*Available Sots: serviceDetailsDiscoveredSlot*/ } void BluetoothModel::serviceDetailsDiscoveredSlot(QLowEnergyService::ServiceState newState) { emit characteristicDiscoveredSignal(characteristic); }
The question now is, how can I divide these things into meaningful components? Should I see each function as a component or rather the whole class?
My approach was e.g to test the scan function by starting it and expecting at least one device to be found. Another Unitests would be with the connect function, I test that the connected signal is triggered when the function is called with a . Is that the right approach? And how can I use the unit tests to test whether a signal is triggered?Another question: is it possible to make Integration tests with QTest´?