Download a free three week trial of UquoniTest

Mocks

UquoniTest has its own mock framework. This allows you to specify at run time what a method in a mock object should do. This could be:

or any combination of these. The If and IfElse constructs let you perform actions only if a condition is fulfilled.

You can also put these in a sequence object, that will perform the next action in it every time it is called. You can also select an action depending on the arguments with a Switch object.

Checking arguments is made easy with ArgsAre and ArgsEqual. In both of these you can ignore certain arguments by supplying Any().

uqtTEST(TestUseBase)
{
    Mock mock;
    mock.m_mock_foo.SetAction(
        uqtMOCK_ASSERT(ArgsEqual(5, "hello", Any()))
    );

    mock.m_mock_bar.SetAction(
        uqtMOCK_CASSERT(ArgsAre(EqualTo(1), Any(), LessThan(10)))
    );
	
    UseBase useBase(&mock);

    ...
}

On top of this you can check afterwards on which threads a method was called, and by which objects in what order if they are connected to a MockCallOrder object.