Ranged tests with parameters

A very useful feature of the TestApe framework, is its ability to execute the same test with a given list of parameters, e.g. a range between 0 and 255, or a set of strings e.g. "", NULL, "SAMPLE" that is known to be of importance for the unit being tested. This also gives the posibility to vary the test slightly, in order to achieve the final increase in coverage. Of course, this can be done by copying existing tests; changing a parameter here and there and implementing new mocks. However - it is much easier to use the possibility to execute a ranged test with parameters using the macro PARAMETER, PARAMETER_RANGE, and PARAMETER_SET.

These macros will prepare one or more values for the next executing test. Suppose you want to test myfunc using a bool input parameter with values true and false, then you would prepare the test using PARAMETER(true); PARAMETER(false); and execute the test as using EXECUTE(myfunc)

Some more examples are shown in the the code below. In the sample directory, sample15 has a more complete working example.2.1

  void interesting_integers(void) {
    PARAMETER(0);
    PARAMETER(-1);
    PARAMETER_RANGE(128,255);
    PARAMETER("some input string");
    PARAMETER("");
    PARAMETER(NULL);
    EXECUTE(interesting_parameters);
  }

This would generate the following output2.2

 Executing test interesting_parameters (step 1 of 133 using value 0)
 ....
 PASSED test interesting_parameters
 Executing test interesting_parameters (step 2 of 133 using value -1)
 ....
 PASSED test interesting_parameters

 ....

 Executing test interesting_integers (step 130 of 133 using value 255)
 ....
 PASSED test interesting_parameters
 Executing test interesting_integers (step 131 of 133 using value "some input string")
 ....
 PASSED test interesting_parameters
 Executing test interesting_integers (step 132 of 133 using value "")
 ....
 PASSED test interesting_parameters
 Executing test interesting_integers (step 132 of 133 using value NULL)
 ....
 PASSED test interesting_parameters

When testing a value in a range from one to 10000, the same test is literally executed 10000 times. This can take some time and generate huge logfiles. As an option, the amount of values tested, and/or the output generated, can be limited from the command line when invoking the test executable. See section [*]

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