0

In QTP, I often report back to the log whenever critical parts of a test either pass or fail. I use the method: Reporter.ReportEvent micPass, "Critical Area of Test", "Things went better than expected"

I would like to detect whether there have been any errors logged to the report by the time I finish the test. The errors I'm looking at aren't anything like Err.Raise InvalidCall; an error would just be anytime I call micFail. By knowing if (and where) a micFail has been called in the test, I could then have a custom function automatically write the results to different areas.

Is it possible to create a function that looks in the default reports to see if the test failed, and if so, which area?

Michael Innes
  • 2,045
  • 5
  • 25
  • 41

1 Answers1

1

You can replace micFail with a custom function that sets an environment variable, and report on that environment variable at a later time.

The custom function would be defined as follows:

Function OnFail()
  Environment.Value("Status") = "FAIL"
  OnFail = micFail
End Function

So every time you would normally use micFail, use OnFail:

Reporter.ReportEvent OnFail, "Subject", "Description"

And at the end of the test, check the environment variable and perform the actions desired:

In Environment.Value("Status") = "FAIL"
  ' ...
End If

Alternatively, you could create a function that replaces Reporter.ReportEvent (it would accept the same parameters and call Reporter.ReportEvent). In this function, you would check the status parameter and perform additional logic based on micFail.

BrianJM
  • 301
  • 1
  • 7