...
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 | ||||
---|---|---|---|---|
|
...
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 | ||||
---|---|---|---|---|
|
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).
- Open test suite file in the Code Editor.
Add a Stub Callback function to the test suite file.
Define the stub logic in the Stub Callback function, using the available input/output parameters.
Tip icon false You can copy the Stub Callback signature from the stub file. See Stub Callback Execution.
You can modify the name of the Stub Callback function, if needed.
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 icon false 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.
- Execute your test case. When the test case is executed, the stub logic you configured will be executed when the stub is called.
...