Adding Unit Tests with GoogleTest

You can create unit tests using the GoogleTest framework and CMake for Knowledge Packs downloaded as the Source format.


  • Recommended Platform: Ubuntu

  • Packages: gtest and cmake

Install GoogleTest and CMake

apt-get install libgtest-dev
apt-get install cmake

Build the GoogleTest Library

cd /usr/src/gtest
cmake CMakeLists.txt
cp *.a /usr/lib

Reference for simple test if you would like to try:

Building and Running Unit Tests

Re-run cmake and rebuild everything


Rebuild only with your modifications


How to Clean


The executable is built in the folder


Additional Notes

  1. will build and run all tests once

  2. will delete out

  3. You can run the test multiple times with --gtest_repeat=N

  4. You can capture test output with --gtest_output="xml:filename.xml"

  5. You can run specific tests with --gtest_filter=MEAN_CALCULATION_TEST.*

Find more info about using GoogleTest:

Adding New Tests

You can add new tests by updating the SENSIML_SDK and KB_UTEST variables in the CMakeLists.txt file

  1. SENSIML_SDK - update with new .c files

  2. KB_UTEST - update with corresponding unit tests new test_*.cpp files