unittest mock improvement and reusability. #53741
Labels
area: Build System
area: Test Framework
Issues related not to a particular test, but to the framework instead
Enhancement
Changes/Updates/Additions to existing features
Is your enhancement proposal related to a problem? Please describe.
The #52894 PR cleaned up the Bluetooth controller unit test significantly by introducing
uut
andmocks
library.However, it still has sub-optimal code like this:
https://github.com/zephyrproject-rtos/zephyr/blob/802eabf43f01b72aef615d48b0f08c05a0f32392/tests/bluetooth/controller/ctrl_feature_exchange/CMakeLists.txt#L11-L12
https://github.com/zephyrproject-rtos/zephyr/blob/802eabf43f01b72aef615d48b0f08c05a0f32392/tests/bluetooth/controller/uut/CMakeLists.txt#L38
See also: #52894 (comment)
Preferable CMake code which creates libraries should be included in the most straight forward way possible, following the folder structure of the repo.
As mocks may be reusable between test suites, then it should be considered how such sharing can be obtained, and the need for
add_subdirectory()
from the toplevel CMakeLists.txt test file is not needed.Describe the solution you'd like
Idea: create common location where CMakeLists.txt are sourced in an heriachy and shared CMake libraries can be created.
Two options:
COMPONENTS unittest
, so that the extra CMake tree is sourced based on knowledge provided by top-level CMakeLists file, for example a call like:It requires more knowledge by the user writing the test, but no build time penalty.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
The text was updated successfully, but these errors were encountered: