Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit tests: Libraries should not contain test-specific logic #14883

Closed
LDong-Arm opened this issue Jul 6, 2021 · 0 comments · Fixed by #14884
Closed

Unit tests: Libraries should not contain test-specific logic #14883

LDong-Arm opened this issue Jul 6, 2021 · 0 comments · Fixed by #14884
Assignees
Labels

Comments

@LDong-Arm
Copy link
Contributor

Description of defect

(Raised from #14870 (comment))

A few libraries check UNITTEST:

$ grep -rn '\bUNITTEST\b'
drivers/include/drivers/MbedCRC.h:32:#ifdef UNITTEST
UNITTESTS/target_h/platform/mbed_assert.h:44:#ifndef UNITTEST
storage/kvstore/tdbstore/tests/UNITTESTS/TDBStore/CMakeLists.txt:10:        UNITTEST
storage/kvstore/filesystemstore/tests/UNITTESTS/FileSystemStore/CMakeLists.txt:10:        UNITTEST
rtos/include/rtos/internal/mbed_rtos_storage.h:20:#if MBED_CONF_RTOS_PRESENT || defined(UNITTEST)
rtos/include/rtos/internal/mbed_rtos1_types.h:20:#if MBED_CONF_RTOS_PRESENT || defined(UNITTEST)
rtos/include/rtos/Thread.h:36:#if MBED_CONF_RTOS_PRESENT || defined(DOXYGEN_ONLY) || defined(UNITTEST)
rtos/include/rtos/mbed_rtos_types.h:20:#if MBED_CONF_RTOS_PRESENT || defined(DOXYGEN_ONLY) || defined(UNITTEST)

But production code should not contain test-specific checks. Instead, fakes/mocks/stubs/... should be enough to wrap any tested modules without modifying interfaces for production uses.

Target(s) affected by this defect ?

N/A

Toolchain(s) (name and version) displaying this defect ?

N/A

What version of Mbed-os are you using (tag or sha) ?

mbed-os-6.12.0

What version(s) of tools are you using. List all that apply (E.g. mbed-cli)

N/A

How is this defect reproduced ?

N/A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants