Test points are implemented as breakpoints at specific line in
source code. They enable us to pause test execution at any location in
the tested code, and perform the following actions:
Verify values of variables.
This feature can be used to test internal state during
function execution.
Assign values to variables.
This feature can be used to test behavior under conditions, which
can not be triggered otherwise, for example to implement fault
injection.
Log values of variables.
These values are stored to reports if we need them for reference anytime later.
Run script function
Scripts can be used when even more flexibility than described
here is required.
Location
Since test point can be located at any line which generates
executable code, we must have a way to tell testIDEA where to set
it. File name and line number are often not a good idea, because
line numbers change as we edit the code. For this reason there
exist several options to define test point location in source
code. Two recommended ones are described below:
If we have access to source code and can modify it, the
recommended way is to put a special comment in the line with test
point. This comment should contain string TID:
<testPointID>, for example: i = 10; // TID:
myTestPoint If single line C++ comments can not be
used, then the following also works:
i = 10; /* // TID:
myTestPoint */
The Source code location dialog
should then look like shown below:
If we do not have access to source code or can not modify it, then
any string in the line with test point can be used, just make sure
it is unique in the given line range.
Note: Not all source code line generate code, and not all
declared local variables exist, especially when we use optimizing
compiler. Test points can be set only on lines which generate
code and can get/set only values of variables which exist. In
winIDEA all source code lines which generate code have
rectangles on the left edge:
Test point hit actions
Since one test point can be hit multiple times during test
execution, we have possibility to specify different
actions for each hit. We can specify the following:
Variables
Assignments to return value, output parameters, and global variables.
Script params
Parameters to script extension function.
Next step
Index of the line with actions to be executed on next test point
hit. If not specified, actions in the next line are
executed on next test point
hit. If the last line does not have this item specified,
it is used on all following test point hits.
Indices of action lines are zero based and are shown in the leftmost
column in the table.
Using hardware breakpoints
See section Stubs in this manual for the description of custom
setting of hardware breakpoints.