Interview Questions

How to Debugg the Tests in WinRunner

Introduction To WinRunner Basics

(Continued from previous question...)

How to Debugg the Tests in WinRunner

Running a Single Line of a Test Script

Choose the Step command to execute only the current line of the active test script —the line marked by the execution arrow. When the current line calls another test or a user-defined function, the called test or function is executed in its entirety but the called test script is not displayed in the WinRunner window. If the user is using a startup application or startup function, it is also executed.

Step Into
Choose the Step Into command to execute only the current line of the active test script. When current line of executing test calls another test or a user-defined function which is in compiled mode the test script of the called test or function is displayed in the WinRunner window. Startup application and function settings (Test Properties dialog box, Run tab) are not implemented. Use Step or Step Out to continue running the called test.

Step Out
User can use the Step Out command only after entering a test or a user-defined function using Step Into. Step Out executes to the end of the called test or user-defined function, returns to the calling test, and then pause the test run.

Running a Section of a Test Script
User can execute a selected section of a test script using the Step to Cursor command.

To use the Step to Cursor command:
Move the execution arrow to the line in the test script from which user want to begin test execution. To move the arrow, click inside the margin next to the desired line in the test script.
Click inside the test script to move the cursor to the line where user wants test execution to stop.
Choose Debug >Step to Cursor WinRunner runs the test up to the line marked by the insertion point.

Pausing a Test Run
User can temporarily suspend a test run by choosing the Pause command or by adding a pause statement to the test script. The test run continues from the point that user invoked the Pause command or from the execution arrow if the user moved it while the test was suspended. The pause statement is ignored by WinRunner when running tests in batch mode.

pause ( [ expression ] );

expression Any valid expression.
The Pause function pause a test run at the current line in the script, and displays a message box. The message box displays the enclosed expression, evaluated to a string. The default message is "Pause." The message box contains two buttons, "Pause" and "Continue." Select Pause to close the message box and pause the test. To resume test execution, select a run command. Select Continue to restart test execution from the point where user invoked pause.

Breakpoint marks place in the test script where user wants to pause the test run. A breakpoint is indicated by a breakpoint marker in the left margin of the test window. User use the Run from Arrow command to restart the test run from the breakpoint. WinRunner only pauses when it is not in batch mode. When running tests in batch mode, WinRunner ignores breakpoints. There are two types of breakpoints.

Break at Location
A Break at Location breakpoint stops a test at a specified line number in a test script.
Example for Break at Location breakpoint appears in the Breakpoints List pane as:
Loc_BP [120]: 0

This means that the breakpoint marker appears in the test named Loc_BP at line 120. The number after the colon represents the pass count, which determines the number of times the breakpoint is passed before it stops the test run. The default value is 0. This means that WinRunner will stop running the test every time it passes the breakpoint.

Break in Function.
A Break in Function breakpoint stops a test when it calls a specified user-defined function in a loaded compiled module. Example for Break in Function breakpoint appears in the Breakpoints List pane as:
Func_Brk [ui_test: 25]: 10

This indicates that a breakpoint has been defined for the line containing the Func_Brk function, in the ui_test compiled module: in this case line 25.The pass count is set to 10, meaning that WinRunner stops the test each time the function has been called ten times. User can set a breakpoint in a function only after the function has been loaded into WinRunner (the function has been executed at least once).

Monitoring Variables
The Watch List enables user to monitor the values of variables, expressions, and array elements while debugging the test script. Prior to running a test, user need to add the elements that user wants to monitor to the Watch List. At each break during a test run —such as after a Step command, at a breakpoint, or at the end of a test, user can view the current values of the entries in the Watch List. User can view the values of variables in the Watch List pane in the Debug Viewer window.

Adding Variables to the Watch List
Go to Debug >Add Watch the Add Watch dialog box opens.
In the Expression box, enter the variable, expression, or array that user want to add to the Watch List.

Click Evaluate to see the current value of the new entry. If the new entry contains a variable or an array that has not yet been initialized, the message “” appears in the Value box. The same message appears if user enters an expression that contains an error.
Click OK .The Add Watch dialog box closes and the new entry appears in the Watch List
To modify an expression in the Watch List Click Modify entry to open the Modify Watch dialog box. Change the expression in the Expression box as needed and click Ok button. The new entry appears in the Watch List

To assign a value to a variable or an array element Click Assign Variable Value to open the Assign Variable Value dialog box. Type the new value for the variable or array element in the New Value box and click Ok button. The new entry appears in the Watch List

To delete a variable or an expression or an array click Delete Entry to remove the entry from the list. User can delete an array only if its elements are hidden. To hide the elements of an array, double-click the array name in the Watch List. To delete all entries in the Watch List Click Delete all entries.

Do not add expressions that assign or increment the value of variables to the Watch List this can affect the test run.

(Continued on next question...)

Other Interview Questions