Asserting behavior


You can verify if methods was called and number of times it was called in the test in various ways. The following API’s are available for this purpose:
  1. ASSERT_WAS_CALLED
  2. ASSERT_NOT_CALLED
  3. TIMES_CALLED

You can verify that a faked method was called

ASSERT_WAS_CALLED:


#define ASSERT_WAS_CALLED ( function )

Verifies that a method, either instance or static was called.
Parameters:
function The method we want to verify if was called.

Remarks:

Use it to check interaction between your tested code to the faked types.
Asserting an instance method was called: 
Example:

ConcreteClass* fakeConcrete = FAKE(ConcreteClass);
fakeConcrete->VoidCall(); / this call is ignored
ASSERT_WAS_CALLED(fakeConcrete->VoidCall());

 



Asserting a static method was called: 

FAKE_STATICS(ClassWithStaticCalls);
ClassWithStaticCalls::VoidCall(); / this call is ignored
ASSERT_WAS_CALLED(ClassWithStaticCalls::VoidCall());

 

 



See also:


ASSERT_NOT_CALLED:


#define ASSERT_NOT_CALLED ( function )

Verifies that a method was not called.
Parameters:
function The method we want to do the verification on.


Remarks:
Use ASSERT_NOT_CALLED to check interaction between your tested code to the faked types.
Example:
ConcreteClass* fakeConcrete = FAKE(ConcreteClass);
 ASSERT_NOT_CALLED(fakeConcrete->VoidCall());
 
 

See also:


TIMES_CALLED:


#define TIMES_CALLED ( function )

Return the amount of times a method has been called.
Parameters:
function The function we want to do the call count on.


Remarks:
Use TIMES_CALLED macro when you want to verify how many times a method has been called through the test.
Example:
ConcreteClass* fakeConcrete = FAKE(ConcreteClass);
 fakeConcrete->VoidCall();
 fakeConcrete->VoidCall();
 int num = TIMES_CALLED(fakeConcrete->VoidCall());
 ASSERT_EQ(2, num);
 
 

See also: