Cantata Logo - unit and integration testing tool for C/C++


UNIQUE CALL CONTROL



Automatically intercept or simulate function
calls for complete 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:

  • Simulate the call interface between the SUT and called objects (whether included in the build or not)
  • Intercept the call interface between the SUT and called objects included in the build
  • Set and check data (accessible to the SUT) when function calls occur
  • Set and check return values back to the SUT or raise exceptions
  • Inject errors to the SUT
  • Check the order of calls made
  • Control each instance of a function call – so that different behaviour can be set/checked for each occurrence

Automatic Wrapping to intercept (not just simulate)  calls is unique to Cantata, providing unparalleled call control for both unit isolation and integration testing. 

Screenshot of Cantata Wrappers Video Cover

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:

  • Stubs to simulate calls to objects not included in the build
  • Isolates to simulate specific calls to objects included in the build.
  • Wrappers to simulate or intercept specific calls to objects included in the build.
  • Dependency Resolver to automatically remove undefined link references

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.  

Cantata Dependency Resolver - determines the missing references - automatically adds the code required to resolve all the undefined references
Cantata Call Interface Conntrol overview chart - generated for function calls made by SUT - global data - third party object code, operating system, compiler library, target firmware, target hardware

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.  

Cantata Wrapping - unique automatic accessibility instumentation - intercept calls through "beofre" Wrappers, "after" wrappers or "replace" Wrappers

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:

  • Simulate Wrapper to replace the call
  • Intercept Wrapper to set / check the interface before and after the call

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.  

Unit Testing - Intercept and simulate calls at unit test - enabled control over specific function calls both inside and outside the compliation boudary
Integration testing - intercerpt and simulate calls at integration and system test - available for any C/C++ function call- check actual interface behaviour

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:

  • Other software components in the build
  • External software (including 3rd party or object code)
  • Operating system or standard library functions
  • Firmware or hardware

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.

Chart of Cantata wrapping Process - use of accessibility instrumentation on a copy of the source code to intercept function calls from the Software Under Test
Cantata Call Interface Control - editing Cantata Call Controls - automatic generating of Wrappers into the test script - default before-after pairing instance - implementation of Wrappers as C/C++ into Cantata test script
Cantata Call Interface Control - editing Cantata Call Controls - automatic generating of Wrappers into the test script - default before-after pairing instance - implementation of Wrappers as C/C++ into Cantata test script

EDITING CANTATA CALL CONTROLS

 

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 Call Interface Control 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.

Cantata Call Order Editing Screenshot - Controlling Calls in test cases - set ecpected order of calls and controlled behaviour for each test case
More information about Wrapping

 

For further information about Wrapping please see our Wrapping feature brief: 

Start
Trial
Learn
more
QA-Systems