Professional > Interview scripting > Writing interview scripts > Additional information > Testing and debugging scripts
 
Testing and debugging scripts
If you are using UNICOM Intelligence Professional to build interview scripts, you can use its Debug (F5) and Auto Answer (F6) features to run interviews. In debug mode, each question is displayed on the Browser tab and you can either enter an answer manually or click F5 again to have UNICOM Intelligence Professional select an answer for you. In auto answer mode, UNICOM Intelligence Professional runs the interview itself and chooses answers for each question. (If you use auto answer with data creation, you can quickly and easily create a case database for analysis tests.) In both cases, any routing in the script is honored as it would be in a proper interview.
There are several ways that you can influence the answers that UNICOM Intelligence Professional chooses:
You can use hints. A hint is an instruction telling UNICOM Intelligence Professional to answer a question in a particular way. For example, you may want the age question always to have the value 50, or the brands preferred question to always be set to A and B. Using hints allows you to test a specific scenario using auto answer without having any manual intervention to set the key responses. See “Using hints” in Running an interview automatically for more information.
You can set break points. These allow you to auto answer an interview up to a certain question and then to switch into debug mode so the remaining questions are displayed one at a time for answering manually. This is useful if you have a problem towards the end of the script and do not want to have to answer every question manually in order to reach the problem area.
For more information, see Testing interview scripts.
Ignoring statements in scripts
Sometimes a script contains statements that you want to ignore when in debug or auto answer modes. Typical examples are quota control statements when you want to test scripts without having to bother about quotas, or a custom validation function that should always pass in test mode, or an error handler that you want to bypass when running in debug mode. You do not have to create a separate version of the script to achieve this; instead, use a single script and flag the statements as not being appropriate in these situations and they will be ignored. You can also achieve the opposite, that is, execute statements only in debug or auto answer modes, in the same way.
To ignore statements when interviews are being run in debug mode (F5), type:
If Not IOM.Info.IsDebug Then
  statements
End If
The following example shows how to bypass a custom error handler when the script is being run in debug mode.
If Not IOM.Info.IsDebug Then On Error Goto __DefaultErrHandler
Goto __StartOfScript

__DefaultErrHandler:
Dim __err_msg, __error
__err_msg = "Script error at line " + CText(Err.LineNumber) + ", " + Err.Description
IOM.Log(__err_msg, LogLevels.LOGLEVEL_ERROR)
If IOM.Info.IsTest Then
IOM.Banners.AddNew("__ScriptErrMsg" + CText(__error), __err_msg)
__error = __error + 1
If __error > IOM.Info.MaxTestErrors Then
IOM.Terminate(Signals.sigError)
End If
End If
Resume Next

__StartOfScript:
The MaxTestErrors property specifies the maximum number of errors that will be displayed in a test survey before the survey terminates. The default value is 9.
To ignore statements when interviews are being run in auto answer mode (F6), type:
If Not IOM.Info.IsAutoAnswer Then
  statements
End If
The following example shows how to have a custom validation function always return True when the script is being run in auto answer mode.
Function ValidateQuestion (Question, IOM, Attempt)
  If (IOM.Info.IsAutoAnswer) Then
    ValidateQuestion = True
  Else
    perform custom check
  End If
End Function
See also
Additional information