The Reporter object in UFT is used for sending information to the default result report in UFT.
UFT Reporter Object Methods
ReportEvent in UFT
ReportHtmlEvent in UFT
1 |
Reporter.ReportHTMLEvent micDone, "Test ReportHTMLEvent", "Reporting Text with Color" |
If you run a Test with the above reporting statement it will look like the following UFT HTML report.
In the result viewer, the same would like the following snapshot.
ReportNote in UFT
1 |
strResultPath = Reporter.ReportPath 'Store the current test's path in the variable |
*Note: Don’t try to set the results folder path using this property as it is only meant to get the path of the current test result folder.
RunStatus in UFT
1 |
intStatus = Reporter.RunStatus 'Numerical value of status is returned |
The numerical value of status is as follows.
- 0 = Pass
- 1 = Fail
- 2 = Done
- 3 = Warning
*Note: The default status of a Test is 2 i.e Done. A Pass event takes precedence over a Done event. A Warning event takes precedence over a Pass event and a Fail event takes precedence over all the events.
Reporter Filter in UFT
The filter property is used to retrieve or set the current mode for displaying events in the run results.
For example, you can only include the event with a warning or fail status in the Run Results.
Syntax:
Reporter.Filter = NewMode
The following are the valid values for mode
Mode | Description |
0 or rfEnableAll | Default. All reported events will be displayed in the Run Results. |
1 or rfEnableErrorsAndWarnings | Only an event with a warning or fail status will be displayed in the Run Results. |
2 or rfEnableErrorsOnly | Only events with a fail status will be displayed in the Run Results. |
3 or rfDisableAll | No events are displayed in the Run Results. |
Example:
Suppressing Pass events in the Run result. Only events with a warning or fail status will be displayed in the Run Results.
1 2 3 4 |
Reporter.Filter=rfEnableErrorsAndWarnings Reporter.ReportEvent micPass,"Test Event Pass","Step should be passed" Reporter.ReportEvent micFail,"Test Event Fail","Step should be failed" Reporter.ReportEvent micWarning,"Test Event Warning","Step should be failed" |
If we run the above code in UFT the Run Result will be as follows:
You can also retrieve the value of the applied reporter filter at runtime using Reporter.Filter statement.