Test points

Concepts ›› Test Case Editor ››
Parent Previous Next

Test points

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:

  1. Verify values of variables.
    This feature can be used to test internal state during function execution.
  2. 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.
  3. Log values of variables.
    These values are stored to reports if we need them for reference anytime later.
  4. 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:

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:

Steps

Since one test point can be hit multiple times during test execution, we have possibility to specify different verification and assignment actions for each hit. This can be done by adding rows with expected expressions and assignments in the table shown below:

Using hardware breakpoints

See section Stubs in this manual for the description of custom setting of hardware breakpoints.