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 log
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
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.
moreNew beta version is now available for download. This is the last beta before official release. The release supports an extensive mocking system.
moreThere is a change for the forum hosted on this site. The previous phpBB forum is closed for now. All forum threads will be migrated to a new simple blog. ...
moreA minor update has been released in order to support GCC when running in a CygWIN environment.
moreThe major update this year has been released. It includes a reference manual and macros to support test parameters and improved usage of the automatic stub instrumentation.
moreThe site has been updated. The webtty package has been tugged safely away in the corner and the TestApe ...
more