An Eclipse CDT plug-in for C++ Seams and Mock Objects¶
Refactoring Towards Seams¶
Breaking dependencies is an important task in refactoring legacy code and putting this code under tests. Feathers' seams help us in this task because they enable us to inject dependencies from outside. But it is hard and cumbersome to apply them without automated refactorings and tool chain configuration assistance. We provide support for seams with Mockator and create the boilerplate code and the necessary infrastructure for the following four seam types:
- Object seam: Based on inheritance to inject a subclass with an alternative implementation. Mockator helps in extracting an interface and in creating the missing test double including all used member functions.
- Compile seam: Inject dependencies at compile-time through template parameters. Extract a template parameter and Mockator creates the missing test double including all used member functions.
- Preprocessor seam: With the help of the preprocessor, Mockator redefines function names to use an alternative implementation.
- Link seam: Mockator supports three kinds of link seams:
- Shadowing functions through linking order (override functions in libraries with new definitions in object files)
- Wrapping functions with GNU's linker option -wrap (GNU Linux only)
- Run-time function interception with the preload functionality of the dynamic linker for shared libraries (GNU Linux and MacOS X only)
Using Test Doubles¶
Mockator offers a header-only mock object library and an Eclipse plug-in to create test doubles in a simple yet powerful way. It leverages new C++11 language facilities while still being compatible with C++03. Features include:
- Mock classes and functions with sophisticated IDE support
- Easy conversion from fake to mock objects that collect call traces
- Convenient specification of expected calls with C++11 initializer lists or with Boost assign including Eclipse linked edit mode support
- Support for regular expressions to match calls with expectations
Read Reporting Bugs to get information about how to report an issue in case of problems.
Try it out now!¶
Follow the instructions in Installation and give it a try!
If you want to know more about us, please also consider our Flyer.
Due to severe budget cuts of our government we, the Institute for Software at University of Applied Sciences of Eastern Switzerland in Rapperswil, require the financial help of our users to keep maintenance and extension of our Eclipse CDT plug-ins continuing. If you are using our plug-in please donate an amount showing your valuation of the plug-in to help. The money will be used to ensure for maintenance and extension of our C++ support with Eclipse CDT exclusively. Please contact us for further information.