In order to maintain software quality and speed development the code is unit tested. Even though the project is written in C, we use Mock Objects to intercept function calls and set expectations.
The unit tests use the gmock and gtest frameworks. To install GMock, run ./install-gmock.sh in the top level project directory. This will download & install gmock / gtest within the local project directory.
Two sets of Mocks are provided:
Any Harmony modules that we use have their API calls proxied through to a mock object. This enables us to stub out the Harmony API for testing. The Harmony mocks consist of a set of headers (found in harmony/include) and the mock harmony objects (in harmony/mocks).
The following is a simple example of how to use the Harmony mocks.
timer.c
TimerTest.cpp
When one Ja Rule module depends on another, it's often useful to be able to mock out the dependency. Ja Rule module mocks can be found in the mocks/ directory. They work in the same way as the Harmony mocks; calls to the module's functions are proxied to a Mock object.
There is also a set of Matchers that can be used to check that binary data passed to functions matches what is expected.