1
0
Fork
You've already forked cppUTest_framework
0
Template to copy/paste on your project.
  • CMake 56.7%
  • C++ 25.8%
  • C 17.5%
2025年03月27日 10:45:53 +01:00
mock add a mock template 2024年10月14日 14:54:24 +02:00
src reorganize repository to be easier usable with cmake as global toolchain 2024年10月14日 14:38:34 +02:00
.gitignore add gitignore 2023年10月24日 20:24:00 +02:00
CMakeLists.txt fix some config var and remove project from ut cmakelists 2024年10月20日 14:23:42 +02:00
config.cmake fix some config var and remove project from ut cmakelists 2024年10月20日 14:23:42 +02:00
custom_cmd.cmake reorganize repository to be easier usable with cmake as global toolchain 2024年10月14日 14:38:34 +02:00
readme.md update readme 2024年10月20日 14:23:18 +02:00
RootCMakeLists.txt fix cmake compile commands setting 2025年03月27日 10:45:53 +01:00

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...

  1. add your mock and stub source.
  2. add your stub header folder to include path.
  3. 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:

  1. move RootCMakeLists.txt to the root of your project
  2. 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