Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space CPPTDESKDEV and version 10.4.1

...

Info

Stub Callbacks require the Enable Stub Callbacks option to be enabled in the Stubs view (see Configuring Stub Options in the Stubs View) or directly in your test configuration (see Execution Tab Settings - Defining How Tests are Executed) before the stub is created.

Anchor
Configuring Stub Behavior in the Test Case Editor
Configuring Stub Behavior in the Test Case Editor
Configuring Stub Behavior in the Test Case Editor

...

See Adding Test Suites and Test Cases with the Test Case Editor - Configuring Stub Behavior for more details about configuring stub behavior using the Test Case Editor.

Anchor
Configuring Stub Behavior in Source Code
Configuring Stub Behavior in Source Code
Configuring Stub Behavior in Source Code

  1. Create a stub for the function you want to configure with the Generate Auto Stub or Create User Stub option (see Adding and Modifying Stubs).
        

  2. Open test suite file in the Code Editor.
  3. Add a Stub Callback function to the test suite file.

  4. Define the stub logic in the Stub Callback function, using the available input/output parameters.

    Tip
    iconfalse

    (tick) You can copy the Stub Callback signature from the stub file. See Stub Callback Execution.

    (tick) You can modify the name of the Stub Callback function, if needed.

  5. Navigate to the test case definition and register the Stub Callback using the following macro:
    CPPTEST_REGISTER_STUB_CALLBACK(<STUB_ID>, &<STUB_CALLBACK_NAME>)

    Tip
    iconfalse

    (tick) You can copy the stub identifier <STUB_ID> from the stub file. See Stub Callback Execution.

    Note

    Ensure that the Callback is registered before the function under test is called.

  6. Execute your test case. When the test case is executed, the stub logic you configured will be executed when the stub is called.

...