In this recipe we will consider scripts debugging by doing a set of step-by-step instructions. This is necessary if we are left with some vague results after test execution, and a simple variable values lookup, at a given point of time, is insufficient.
To begin, we will require two functions, one of which is to be called from the other:
fn1
:function fn1() { var n = 5, s = "str"; Log.Message(n); Log.Message(s); return s; }
main
so that it calls the first one twice, and then outputs the results into the log, as obtained due to the fn1
function call:function main() { var res1 = fn1(); var res2 = fn1(); Log.Message(res1); Log.Message(res2); }
In order to perform step-by-step execution in the debugging mode, it is necessary to complete the following actions:
main
function (to this end, set the cursor at this line, and press F9 button).main
function. In the result, the function execution will pause.fn1
function will come through; the res1
variable will have the str
value assigned.fn1
function.fn1
function, and we will have a possibility to execute the function step by step by pressing F10 key.In the debugging mode, we can perform the following commands:
Step Over
command is to be executed.