Wednesday, April 27

QTP Reporter Object - Send messages to QTP Result file

Hello Friends!

In this post, we'll see how to customize and manage the information in QTP Test Result file. Test Result is automaticaly generated after every test run.

Reporter Object is used for sending information/message to the QTP test results. Following are the method/properties we can use with ‘Reporter’..

•    ReportEvent Method
•    Filter Property
•    ReportPath Property
•    RunStatus Property

ReportEvent Method

ReportEvent is commonly used method od Reporter and most of you must be already aware of this!

As the name suggest, it reports an event to the test results. Means, by using Reporter.ReportEvent, you can send information to QTP test result file.

Reporter.ReportEvent EventStatus, ReportStepName, Details

As we can see above, ReportEvent takes 3 arguments. Let's discuss these briefly-

EventStatus:  Status of the step i.e. Pass/Fail etc. It can be four types..

0 or micPass: Causes the status of this step to be passed and sends the specified message to the report.

1 or micFail: Causes the status of this step to be failed and sends the specified message to the report. When this step runs, the test fails.

2 or micDone: Sends a message to the report without affecting the pass/fail status of the test.

3 or micWarning: Sends a warning message to the report, but does not cause the test to stop running, and does not affect the pass/fail status of the test

ReportStepName: It is name of step. It can be any string value.

Details: It is also any string value. You should provide description of steps here.

Example of ReportEvent Method

The following examples use the ReportEvent method to report a failed step.

Reporter.ReportEvent 1, "Custom Step", "The user-defined step failed."
Reporter.ReportEvent micFail, "Custom Step", "The user-defined step failed."

You can leave last two arguments (ReportStepName and Details) blank as well but recommended.

Reporter.ReportEvent 1, "", ""
Reporter.ReportEvent micFail, "", ""

Okay friends! It was most important part of Reporter. Let's quickly discuss remaining three properties also.

Filter property

Using Filter property, you can instruct QTP about what type of event to display in result.

Reporter.Filter = Mode

What is the use of Filter property?

Filter is used if you dont want to display all types of events in QTP test result. For example you have 10 Reporter.ReportEvent statements in your test (5-
Pass and 5-fail). By default all 10 will be displayed in result. You can use Filter if you want to display only pass or only fail events in the result. One way to comment all unwanted type of Reporter statements, but what if you can do that by writing just one line in your code!

There can be four types of Filter modes..

0 or rfEnableAll: This is the default mode. All reported events are displayed in the Test Results.

1 or rfEnableErrorsAndWarnings: Only those events with a warning or fail status are displayed in the Test Results.

2 or rfEnableErrorsOnly: Only those events with a fail status are displayed in the Test Results.

3 or rfDisableAll: All events in the Test Results are disabled. No event will be displayed in result file.

Example of Filter Property:

Reporter.Filter = 2
Reporter.Filter = rfEnableErrorsOnly

ReportPath Property

It simply retrieves the folder path in which the current test's results are stored.

Do not use this property to attempt to set the results folder path. Means it is used for 'getting the path' not 'setting the path'.

Path = Reporter.ReportPath

Example of ReportPath Property

Dim Path
Path = Reporter.ReportPath
MsgBox (Path)

Above example uses the ReportPath property to retrieve the folder in which the results are stored and displays the path in a message box.

RunStatus Property

It retrieves the run status at any particular point during the run session. For tests, it returns the status of current test during the test run.


Example of RunStatus Property

If Reporter.RunStatus = micFail Then
  Msgbox "Run Status is fail. Exiting from Action iteration."
End If

Above example uses the RunStatus property to retrieve the status of the run session at a specific point and exit the action if the test status is fail. If the test status is not fail, the test run continues.

In case of any queries/suggessions, please post your comments.


  1. Nice explanation.

  2. thanks for explanation

  3. Hi
    can u plz help me to ans these questions.

    1)Why we import the data from excelsheet to datatable and using it as datatable parameter...while we can use the value directly from excel sheet using excel application model .


    What is the advantage over using datatable input over excel input in our script?

    2) How to log defect after executing a script in qtp ?

  4. @Ranjan

    Exporting sheets to datatable have several benefits of its own, for example..

    Its more convenient at the time if you have lots of columns in the datatable. By importing shhets to Datatable, you can refer column by its name (which is not feasible to do using Excel COM)

  5. Hi, gud explanation,
    can u tell me how to wrap reporter.reportevent in a function .. so that it can be called and passed arguments whenever required in the script

  6. Hi ,can i delete all temp files directly from temp folder in QTP?
    if i delete is there any problem to face while running the script?cause my QTP became very slow... pls help me...

  7. This comment has been removed by the author.

  8. You can tell for instance if the understudies are rehearsing moves for self preservation or on the off chance that it is rivalry sort of preparing. Likewise you can see whether they are about youngster or grown-up preparing. taekwondo school in lees summit mo

  9. Nice information and bery useful for all of us.

  10. Great job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too please do keep sharing more blogs like this.

    IELTS Coaching in chennai

    German Classes in Chennai

    GRE Coaching Classes in Chennai

    TOEFL Coaching in Chennai

    spoken english classes in chennai | Communication training