Organizing tests

When running the above tests, the framework validates that all the expected functions are called in the order as defined by the test and that no unexpected function was called. The test will validate if the parameters were correct and simulate the output as defined by the test. At the very end, the framework will validate the data returned from the unit. This would look something like this in the log2.2

 Executing test test_addition
 
   Expecting function call to invalid
   Expecting function call to invalid
   Expecting function call to add
 
   In stub invalid
 
   PASSED verify function call to invalid
     expected .......... invalid
     actual ............ invalid

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

   In stub add
  
   PASSED verify left_operand
     expected .......... 3 (3)
     actual ............ 3
 
   PASSED right_operand
     expected .......... 7 (7)
     actual ............ 7
 
   PASSED verify calculate(3,7,'+')
     expected .......... EXPECTED_SUM (10)
     actual ............ 10
 
 PASSED test test_addition

In order to test the entire module and not just one function several tests must be combined - for example, software that operates in an event driven environment will typically implement some kind of state machine. In those environments, several events are required to test the unit and a complete test scenario may require several tests to be executed. TestApe post no restrictions on how the tests are organized. In fact, they can be nested to allow for whatever test organization that is appropriate for testing the unit. e.g. the nested test below would be executed using EXECUTE(scenario_sunshine)

  void scenario_sunshine(void) {
    EXECUTE(test_receive_this_event_wait_for_that_event);
    EXECUTE(test_receive_that_event_and_finish);
  }

It is also common to group several tests to form testcases and testsuites. It is a possibility for the test designer to form testcases by nesting tests and to form testsuites by nesting testcases. This is illustrated in sample14 shown below.2.1

  void test_mapping_minus(void) {
    EXPECT  ( invalid );
    EXPECT  ( invalid );
    EXPECT  ( subtract );
    calculate(1,1,'-');
  }

  void test_mapping_plus(void) {
    EXPECT  ( invalid );
    EXPECT  ( invalid );
    EXPECT  ( add );
    calculate(1,1,'+');
  }

  void testcase_operator_mapping(void) {
    EXECUTE(test_mapping_plus);
    EXECUTE(test_mapping_minus);
  }

  void testsuite_calculator(void) {
    EXECUTE(testcase_operator_mapping);
  }

  void testmain(void) {
    EXECUTE(testsuite_calculator);
  }

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