Less work with MockPlugin

CppUTest plugins can be installed in the main and 'extent' the unit test framework. It is a place where you can put work that needs to be done in all unit tests. There is a MockPlugin to make the work with mocks easier. It does the following work:

  • checkExpectations at the end of every test (on global scope, which goes recursive over all scopes)
  • clear all expectations at the end of every test
  • install all comparators that were configured in the plugin at the beginning of every test
  • remove all comparators at the end of every test

Installing the MockPlugin means you'll have to add to main something like:

    MyDummyComparator dummyComparator;
    MockSupportPlugin mockPlugin;

    mockPlugin.installComparator("MyDummyType", dummyComparator);
    TestRegistry::getCurrentRegistry()->installPlugin(&mockPlugin);

This code creates a comparator for MyDummy and installs it at the plugin. This means the comparator is available for all test cases. It creates the plugin and installs it at the current test registry. After installing the plugin, you don't have to worry too much anymore about calling checkExpectations or cleaning your MockSupport.