Python script to generate cpp mock for FSeam
A seam is a term introduced by Michael Feathers in his book Working effectively with legacy code. It basically describe a way to change the behavior of a function/functionality, which is very usefull for testing while ignoring external dependencies.
A lot of different seams exist and are described in this accu article that is a must read.
When talking about seam, for FSeam, it is assumed we are talking about link seam.
The goal of such seam is to change the behavior of a class by tweaking the ordering, number of the files compiled. FSeam is a combination of a code generator (creating a mocking implementation of the given C++ class/functions) and a header only library that makes you able to change the behaviors of those mock at runtime. And a CMake helper in order to easily implements the generation of code and linking time tricks.
Why do we need yet another mocking framework?
FSeam python script is used to generate cpp files that contains implementation of class, this is a what we will call a seam mocked implementation. This implementation is going to replace the actual implementation at Linking time (thanks to CMake helpers functions). And thanks to the header only FSeam library, you will be able to manipulate those mocks (changing behavior, verify usage).
- Mocking without impacting production code
- Mocking default behavior (no need to access a particular instance of the mocked object to manipulate its behavior)
- Mocking of static / free functions as easily as any classes
- Easy to setup (all of those thing are installed and ready to use when following the installation step below):
- Header only library to include in test file
- A Python script
- CMake file to include in order to easily do the compile tweaking and code generation
git clone https://github.com/FreeYourSoul/FSeam.git
cd FSeam
mkdir build
cd build
cmake ..
make && make test && sudo make install
In case of dependencies issue : follow this link
Using extensively CppHeaderParser, originally developed by Jashua Cloutier(original repo)
The project is currently handled by robotpy (current repo)