Reporter Method for rewriting qtp

Source: Internet
Author: User

For
Qtp
Of
Reporter
Object.
Registeruserfunc
Methods, like rewriting other test object methods to customize our own
Reporter
Object and register it.

 

However
Yaron Assa
Here is a solution:

Http://www.advancedqtp.com/community/blogs/yaron-assas-blog144/overriding-qtps-native-reporter/

 

This method writes
Reporter
Class with the same object name:

'Override it with our custom class

Dim reporter

Set reporter = new clsreporter

 

'Define a funnel function to be called from
The test actions

Public Function getreporter



Set getreporter = Reporter

End Function

 

'Class Definition

'In the example, our class just reporter
A text file

Class clsreporter



Dim ofilereporter



Public sub reportevent (istatus, sstepname, sdetails)



Ofilereporter. appendalltext "C:/log.txt", istatus &"
: "& Sstepname &"-"& sdetails & vbcrlf



End sub

 



Private sub class_initialize



Set ofilereporter = dotnetfactory ("system. Io. File ")



End sub

End Class

 

Then
Action
Definition
Reporter
And get the object to use, so that
Reportevent
The method is our custom method, instead
Qtp
Of
Reportevent
Now:

Dim reporter

Set reporter = getreporter

Reporter. reportevent
"Fail", "stepname1", "stepdetails"

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.