I am using
cmockaas the unit test framework to illustrate the concepts used in my book “a Guide to Success Unit Tests”.
cmakebuild system to help it build the
cmockadynamic library as well as the test scripts into executables. So
cmakewill have to be installed as well as
cmockafor it work correctly.
cmakecan be downloaded from
cmockacan be downloaded from
The I am using a MacOS computer, so my references are from using that computer.
cmake, many different packaging versions can be downloaded. Since my computer is a MacOS, I downloaded the .dmg package. After I have extracted and installed it, I added it path the
I test that it can find it by getting it to report is version number.
localhost:~ tehnyitchin$ ccmake --version
ccmake version 3.3.0
CMake suite maintained and supported by Kitware (kitware.com/cmake).
Checking cmocka is working
Once you have downloaded
cmockaand unpacked it, you can test if the
cmockaare going to work correctly. The file README has the correct instructions. In the example below, I have unzipped
cmockainto a directory called
After the build, the test binaries are in subdirectory
example. Executing one of the test binaries will execute the test scripts. Below is a execution of
localhost:example tehnyitchin$ ./simple_test
[==========] Running 1 test(s).
[ RUN ] null_test_success
[ OK ] null_test_success
[==========] 1 test(s) run.
[ PASSED ] 1 test(s).
I am writing a Guide to Successful Unit Tests, you can get it here at Leanpub