Testing what happens when function calls from the Software Under Test (SUT) are made, is integral to all levels of dynamic testing. Cantata call interface control automatically generates the necessary test framework for these interfaces, making it easy to:
Automatic Wrapping to intercept (not just simulate) calls is unique to Cantata, providing unparalleled call control for both unit isolation and integration testing.
What is Cantata Call Control?
Cantata call interface controls are automatically generated for all function calls made by the Software Under Test (SUT) e.g. to other functions in the same or other files, 3rd party object code, operating system / compiler library, or target firmware / hardware. Users have complete control over the appropriate style of Cantata call control to be generated for each call made from each function:
Each type of Cantata call control is written in C/C++ as appropriate, giving a test control point in the execution flow to set and check data available to the SUT (e.g. global data or hardware registers) and parameters/returns. As each control type can also have multiple instances, different behavior and call order can be set or verified each time a call is made in each test case scenario.
Isolation of C++ for testing from the remainder of the code base, can result in a lengthy daisy-chain effect of undefined references at link time when building test executables. Cantata Dependency Resolver determines the missing references and automatically adds the code required to resolve all the undefined references (methods or variables).
The various Cantata call controls give testers the flexibility to choose simulation or interception as needed to drive and verify the code.
What is Cantata Wrapping?
Wrapping is a unique automatic accessibility instrumentation that intercepts or simulates function calls. It goes far beyond traditional simulations (e.g. stubs, mocks, fakes etc), providing more flexibility for testing interfaces when objects are integrated together.
Automatically generated Wrappers intercept calls before the call (BEFORE Wrappers), after the call (AFTER Wrappers), or can replace the original call with a simulation (REPLACE Wrappers).
Where a Cantata test script is used, BEFORE, AFTER and REPLACE sections of the Wrapper are written to the test script. Wrapping can also be used outside a Cantata test script to provide call interface control with other test drivers.
What does Wrapping help me do?
INTERCEPT & SIMULATE CALLS AT UNIT TEST
Unit testing verifies one or more functions without the rest of the system. Traditional call controls (e.g. stubs, mocks, fakes dummies) only simulate called objects excluded from the compiled software unit under test.
Cantata Wrapping enables control over specific function calls both inside and outside that compilation boundary. Specific calls to functions can be controlled with:
Each Wrapper also allows setting/checking of all accessible data when the calls are made.
Wrapping uniquely gives automated control inside the compilation boundary (e.g. functions calling other functions in the same file or class), and also greater tester choice in defining what is included in the unit testing boundary for isolation or cluster unit testing.
INTERCEPT & SIMULATE CALLS AT INTEGRATION & SYSTEM TEST
Integration & systems testing verifies the actual interaction between multiple units, so the more units are integrated, the less useful replacing those units with simulations becomes. Cantata Wrapping at integration & system testing retains all the benefits of Wrapping at unit testing, but it becomes even more useful to simulate or intercept specific calls when testing the actual interactions.
Cantata Wrapping interceptions are available for any C/C++ function call made from anywhere within the software under test to:
Cantata Wrapping interceptions allow the tester to check actual interface behavior, rather than use test scenarios based on assumptions in a simulation. Interception of calls provides unparalleled capability inject errors and verify actual behavior of actual interactions (e.g. failures with operating systems, 3rd party code, firmware and hardware) which are otherwise impossible or too expensive to test.
How does Wrapping work?
Cantata Wrapping uses accessibility instrumentation (via the GUI or CLI) on a copy of the source code to intercept function calls from the Software Under Test (SUT).
Anything called by a C/C++ function call can be Wrapped (e.g. another function, a 3rd party object, a database etc). A Wrapper has an identical function prototype to the called object being replaced, but testability instrumentation allows the called object to be included in the test build without causing linker errors.
The BEFORE, REPLACE and AFTER Wrapper sections insert programmable additional C/C++ functions, which then call: another Wrapper section, the called object or pass back to the SUT. Each Wrapper section contains Cantata directives to record call order, modify or check parameters / exceptions and all data accessible to the SUT or called object, and returns.
EDITING CANTATA CONTROLLED CALLS
Cantata automatically generates each Wrapper (containing BEFORE, AFTER and REPLACE sections) into the test script with a default BEFORE-AFTER pairing instance. This means that called objects can be Wrapped without forcing the tester to specify the return value.
Additional Wrapper instances (in either Before-After or Before-Replace pairings) may be added to check all parameter values passed to and from the called object. When additional instances are added, Cantata automatically offers checks of actual against expected values for all the parameters passed over the interface.
A function call to an object, can have all calls Wrapped or just selected calling functions.
Wrappers are implemented as C/C++ into a Cantata test script, and can be edited in the Cantata GUI, or directly using any C/C++ editor.
CONTROLLING CALLS IN TEST CASES
Cantata call interface controls can use multiple instances stubs, Wrappers or isolates to provide different behaviors on different occasions the call is made. These controlled calls and instances are used in a Cantata test script to set the expected order of calls and controlled behavior for each test case.
Expected Call Sequences are very flexible (linear, fixed size loops, parallel etc.), and can be set for specific orders or any time matches for each controlled call. The order of expected calls in each test case can be edited in the Cantata GUI (test script manager) or directly in any C/C++ editor.
More information about Wrapping
For further information about Wrapping please see our Wrapping feature brief: