- CMake 56.7%
- C++ 25.8%
- C 17.5%
| mock | add a mock template | |
| src | reorganize repository to be easier usable with cmake as global toolchain | |
| .gitignore | add gitignore | |
| CMakeLists.txt | fix some config var and remove project from ut cmakelists | |
| config.cmake | fix some config var and remove project from ut cmakelists | |
| custom_cmd.cmake | reorganize repository to be easier usable with cmake as global toolchain | |
| readme.md | update readme | |
| RootCMakeLists.txt | fix cmake compile commands setting | |
CppUTest Framework
This repository is a template design for embedded C code unit test. To you use it you must install gcc, cmake, pkg-config and make or ninja.
Folder Struct
HowTo
Adding the template to your project
/!* This framework must be copy only.*
So to add it to your project you must:
git clone https://codeberg.org/tanche/cppUTest_framework tests
cd tests
rm -rdf .git
Configure your project
To configure your project, edit config.cmake to add your sources files, header folder, ut files, moc...
- add your mock and stub source.
- add your stub header folder to include path.
- replace src/example.cpp by your ut files.
Case 1: No CMakelists
Your lib/project does't rely on cmake toolchain to be compiled. So in the root folder they aren't any CMakeLists.txt file. In this case follow this steps:
- move RootCMakeLists.txt to the root of your project
- configure it to add src files and inc dir of your project
Case 2: You Already use cmake
You already use CMake as project manager, congratulations. To add your new unit test folder: tests to your config you should add:
enable_testing()add_subdirectory(tests)and be sure that you configure include dir as public:
target_include_directories(YourLib PUBLIC inc_dir)Compilation and test running
cmake -B build
cmake --build build -j4
ctest --test-dir build --output-on-failure
To force recompilation, add the --clean-first option the build line :
(tu)> cmake --build build --clean-first -j4
Code coverage
ToDo refactoring unit test code coverage base on gcov