Unique Call Control
Automatically intercept or simulate
function calls for complete control
Leverage C/C++ Dynamic Testing with Cantata Call Control
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:
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 generated for each call made from each function:
Each type of Cantata call control is written in C/C++ as needed, providing 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. Since 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 required code to resolve all the undefined references (methods or variables).
The various Cantata call controls provide testers flexibility to choose simulation or interception as needed to drive and verify the code.
Optimize C/C++ Testing with Cantata Call Controls
Discover how Cantata can help you achieve more robust automated testing.
The Power of Wrapper Functions for Automated Testing
Wrapper functions are a game-changer for automated testing. These unique functions automatically intercept or simulate other function calls. They go beyond traditional test doubles like stubs or mocks by providing more flexibility when integrating and testing components.
Automatically generated wrappers can intercept calls before, after, or entirely replace the original call with a simulation. When used with a Cantata test script, the wrappers generate code for before, after, and replace sections. Wrappers enable call interface control even outside of Cantata with other test drivers.
Automate Unit Testing with Wrapper Functions
Wrappers help automated unit testing in two key ways:
Wrappers give more control over specific calls than traditional test doubles. You can intercept calls to functions inside the test boundary like those between classes in the same code file. Wrappers also allow flexibility in defining isolation levels for 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: