Validating function calls

The implementation of calculate depends upon the functions validate, add, divide, multiply and subtract in order to implement the calculations. For a given test, there is a certain order in which these are executed. This is tested using the macro EXPECT as it is shown in sample4 below.2.1

  void test_addition(void) {
    EXPECT( invalid );
    EXPECT( invalid );
    EXPECT( add );
    calculate(3,7,'+');
  }
With the EXPECT macro the test developer can indicate to the framework, that this test expects invalid() and add() function calls during calculate. The framework detects the function calls made by calculate and generates the output shown below2.2
 Executing test test_addition

   Expecting function call to invalid
   Expecting function call to invalid
   Expecting function call to add

   PASSED verify function call to invalid
     expected .......... invalid
     actual ............ invalid

   PASSED verify function call to invalid
     expected .......... invalid
     actual ............ invalid

   PASSED verify function call to add
     expected .......... add
     actual ............ add

 PASSED test test_addition

The calculate function do not see any difference compared to its normal environment.

If the expected function is not present in the unit, the framework will report that it is called and return 0 to the unit that is calling it. If the function is present in the unit, the framework will simply report that it is called and afterwards call the function.



testape

News

The latest headlines from Testape.com

TestApe Release 1171 available, Aug 20th 2014

It has been a long time since last official release and the list of bugfixes, features and supported platforms accumulating in the beta has grown substantially. I am happy to annouce that a new release is ready.

more

TestApe beta version available, Jul 21th 2014

New beta version is now available for download.

more

TestApe Release 880 available, Dec 3rd 2011

New is this release are support for floating point validations and function mocking. Also, MinGW has been added to the list of supported platforms.

more

Forum change, Mar 27th 2011

TestApe forum is now hosted on Proboards. Support questions can be posted here or send directly on email. Due to ...

more

TestApe beta release available, Sep 27th 2011

TestApe can now be used with MinGW GCC on windows. Also supported in this beta are floating point types in validations or when mocking functions

more

IPad update for WebTTY, May 15th 2011

A small fix for webtty scripts, to allow the usage from Apple IPads. Tab on textarea to bring up IPad keyboard - you may have to scroll webpage beneath keyboard, in order to actually see what you're typing.

TestApe Release 791 available, Apr 2nd 2010

This release contains a new flexible mocking system with default mocks automatically generated for unresolved functions. Installation packages are available for GCC/Linux, GCC/CygWin as well Visual Studio 2009/Windows XP or Vista.

more