Writing messages to the log
A log is a file that contains the record of events that occur while a Functional Test script is playing back. There are several different methods you can use to write messages to the log.
HCL OneTest™ UI supports several types of log files, or no logging at all. You select the type of log file ( HTML log, or text log) through the user interface. Each logged event has an associated message.
HCL OneTest™ UI automatically logs these events:
- Script start
- Script end
- Calls to the callScript method
- Calls to the startApplicaction method
- Timer start
- Timer end
- Exceptions
- Verification points
To use the scripting SDK to include your own general messages in
whatever type of log you specified through the user interface, use
the logInfo
method, as shown in this example:
if(AnAWTButtonButton(p1,0)isEnabled())
{
logInfo("AWT button is enabled.");
}
else
{
logInfo("AWT button is not enabled.");
}
With the scripting framework, you can log a test result by using
the logTestResult
method. The first parameter is
a headline that describes the test. The second parameter is the result
of the test (true
for pass, false
for
a failure),. An optional third parameter is for additional information.
For example:
logTestResult("Text buffer comparison",
TextField_text.equals(msExpect));
Here is another example that uses the third parameter for additional information:
if(TextField_text.equals(msExpect))
{
logTestResult("Text buffer comparison", true);
}
else
{
logTestResult("Text buffer comparison", false,
"Expected '"+TextField_text+"' but found '"+msExpect+"'");
}
If you want to use the scripting framework to write an error message
to the log, use the logError
method:
catch (Exception e)
{logError("Exception e = "+e.toString());}
With the scripting SDK, you can add a warning message to the log
using the logWarning
method:
logWarning("Your warning message goes here.");