To pause automated test execution at a specific point, the breakpoints are applied. In this recipe we will learn to work with the breakpoints in TestComplete.
Create the following function:
function testBreakpoints() { for(var i = 0; i < 10; i++) { Log.Message("Iteration #" + i); } }
This function will simply output the messages 10 consecutive times.
To demonstrate working with the breakpoints, perform the following steps:
Log.Message
method call and press the F9 key (or click on the column with the numbers to the left of the editor, opposite the previous line). In the result, the line will be highlighted in red against its background, and in the column to the left, a red circle will appear, as shown in the following screenshot:Log.Message
line.i == 4
in the Condition field and click on the OK button:In the first instance we have used a simple breakpoint. It fires as soon as script execution reaches the given code line and pauses the execution, pending further action from the user.
In the second instance, we have used a conditional breakpoint, which allows pausing the execution only in case a certain condition is met (in our case, the variable i
should be equal to 4
).
Conditional breakpoints are very convenient in those cases when we have a loop, which is executable in part by pausing the execution under conditions specified.
Besides a condition of the kind, one can make use of another condition of Pass Count. In this field, it is possible to assign the number of loops of the script, after which the breakpoint should fire (for example, in our case, we could simply set the value to 4
in the Pass Count field).
There also exists another method for setting a conditional pause into the script execution, namely that of the Runner.Pause
method. The result of this is analogous to the workings of the breakpoint.
If you have a breakpoint, which is of use from time to time (for example, a non-stable script, often requiring debugging), we can simply disable the breakpoint instead of completely removing it. To this end, it is necessary to right-click on it and select the Enable menu item.
3.145.191.134