I am using UFT 12.02. In the function library I have a function as ReportEvent(Status, TestStep, ExpectedResult, ActualResult, OptionalLink) and another function with the same name as ReportEvent(TestStep, ExpectedResult, ActualResult).
when I call the ReportEvent function in my script it calls the function that mentioned at the highest LOC of the two i.e. the last one to be written.
it doesn't stop my work but my curiosity got better of me and I thought may be y'all might be able to help.
okay I found an answer to this, swiftly hopefully - it is based on the check rules of vbscript, which in hierarchy are as follows:
- Code is parsed line by line, last function definition with same name in same location is used.
- If matching function is available in function library loaded using ExecuteFile code, it is used. Otherwise…
- if matching function is available in action code, it is used. Otherwise…
- if matching function is available in function library loaded using LoadFunctionLibrary code, it is used. Otherwise…
- if matching function is available in statically associated function library, definition from top-level associated function library is used
So particularly for my question - the matching function in library file which is written last will be used when called in the action. So - ReportEvent(Status, TestStep, ExpectedResult, ActualResult, OptionalLink) at LOC-50 and ReportEvent(TestStep, ExpectedResult, ActualResult). at LOC -105
then the one at LOC - 105 is used.
来源:https://stackoverflow.com/questions/32824427/why-only-the-latest-function-is-called-if-the-function-name-are-same-in-uft-12