Inserting timing constraints

You can define timing constraints directly in the test behavior code or from the test data table (TDT) to measure the duration of a method call or a sequence of method calls.

To add a timing constraint:

  1. Open the test behavior source code in the Java editor. (To find the source code, open the Package Explorer view, expand the test project you are storing the test in, and expand the Behavior folder.)

  2. Position the cursor at the location in the code where you want to start the timer.

  3. Right-click and click Component Test > Insert timer.

  4. Specify a name for the timer.

    The starting point for the timer is added to the test behavior code. For example, if the timer is named timersetrate, the following code is added:

    ComponentTest.startTimer("timersetrate");

  5. Position the cursor at the location in the code where you want to end the timer.

  6. Right-click and click Component Test > Insert timer validation.

    The timer validation is added to the test behavior code, and a new row is added to the test data table at the point where the timer needs to be verified. For example, if the timer is named timesetrate, the following code is added:

    ComponentTest.checkTimer("timersetrate");

  7. In the test data table, insert a timing constraint for the timer. For example, to verify that the total time of completion for the methods you are timing is greater than or equal to 2 milliseconds, define the value in the test data table row as > = 2 ms.

 

Related concepts

Timing constraints
Component testing and the Java editor
Stub behavior