How do I add my own custom debugging output to a Test Composition?
|A Script can post custom log entries to the Result for the Test Composition.
You can place such Scripts within your Test Composition at the points at which you wish to generate log entries.
You can place also generate custom log entries throughout your Scripts to output debugging information, either to debug the Script itself, or to debug other portions of the Test Composition. Such debug logging could be conditionally enabled through the use of a Global Property - see the question "How do I parameterize a Test Composition (or its components) so that I can change the behavior each ..." for further information about using Global Properties for such purposes.
|A Script posts log entries to the Result by calling the "postMessage" method of the Result object:
The above example posts a log entry with title text only:
|Title text is limited to 255 characters. An optional third parameter may be given to specify "detail" text for the log entry. Detail text may be long and consist of multiple lines:
The above example posts the following log entry:
|The log entry may be posted at any of the supported levels, and will be logged only if the logging level for Scripts is set for the Test Composition such that entries of that level are to be logged:
The logging levels for the Test Composition are set in the "Logging" tab in the Composition Editor:
|An In Situ Substitution Expression (ISSE) can also be used to post an entry to the Result, because an ISSE can contain a Scripting expression. Refer to the separate question "How do I dynamically or programmatically substitute a value into a Message or Browser Action before it is sent or played?" or to the ISSE documentation, for more information on ISSEs.
Although generally intended to be used to insert a value into a Message or Browser Action, if an ISSE contains Scripting it can also have the side effect of creating log entries. If the ISSE returns no value to be inserted into the Message or Browser Action, then effectively it's entire purpose could be to generate a log entry before the Message is sent or the Browser Action is executed.
|An example of this is shown here. Because of screen size limitations the entire ISSE is not visible, however the contents of the "inputValue3" field are: