Micro Focus QTP (UFT) Forums
I want to not fail on handeled run error in web service test - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: I want to not fail on handeled run error in web service test (/Thread-I-want-to-not-fail-on-handeled-run-error-in-web-service-test)



I want to not fail on handeled run error in web service test - sanavab - 03-06-2011

Hi All,
I am beginner in QTP and using version 10 of QTP for functional testing of webservices. but a problem. i could test a correct state of my webservice successfully but for state that my webservice have to return a error that i expected, it fail when i test it. i said to it :
if ( isExpectedErrorOccure ) Reporter.ReportEvent micPass, "Login Test", "test reason: passed."
But when the webservice return a correct handled error it set the test result to failed, but for me it is passed. Sad
What should i do for this problem?
Thanks a lot.
My test script is such below:
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Code:
WebService("ServicesService_2").login XMLWarehouse("userBean")
testError = WebService("ServicesService_2").GetLastError
if  ( reason = "Incorrect password" )  then
expectedError = "User name or password is incorrect!"
isExpectedErrorOccure = InStr(testError, expectedError)
if(isExpectedErrorOccure >0) then
Reporter.ReportEvent micPass, "Login Test",  "test reason: " & reason & " passed."
else
Reporter.ReportEvent micFail, "Login Test",  "test reason: " & reason & "  failed."
end if
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


RE: I want to not fail on handeled run error in web service test - Jenny - 03-07-2011

may be it shoud be

Code:
if(isExpectedErrorOccure <0) then
Reporter.ReportEvent micFail, "Login Test", "test reason: " & reason & " failed."
else
Reporter.ReportEvent micPass, "Login Test", "test reason: " & reason & " passed."



RE: I want to not fail on handeled run error in web service test - sanavab - 03-07-2011

Thank you Jenny,
Really excuse me about my poor English.
exactly my problem is about < WebService("ServicesService_2").login XMLWarehouse("userBean") > ..when it run this line it return a run error but for me it is true and expected error that i handled in my webservice and i want to pass it. what is the solution?
for example in script above when i enter a Incorrect username and password for the login service, the expected error is "User name or password is incorrect!". i want when it return this error message i pass it but it return a run error because of Incorrect password. no deference between unhandled error and handled error ... Sad
I attached a print-screen of my test result that may be useful for problem understanding. Smile


RE: I want to not fail on handeled run error in web service test - basanth27 - 03-07-2011

You must forgive my neurons, they have been having a hard time, but if i have got what you said, then i believe, this is what you are looking for,

Code:
On Error Resume Next
WebService("ServicesService_2").login XMLWarehouse("userBean")
testError = WebService("ServicesService_2").GetLastError
if  ( reason = "Incorrect password" )  then
     expectedError = "User name or password is incorrect!"
if InStr(testError, expectedError) <> 0 then
      Reporter.ReportEvent micPass, "Login Test",  "test reason: " &        reason & " passed."
else
  Reporter.ReportEvent micFail, "Login Test",  "test reason: " & reason    & "  failed."
End if
msgbox Err.Number &" "& Err.Description
End if
Let me know if this works?


RE: I want to not fail on handeled run error in web service test - sanavab - 05-21-2011

Hey All...
service test 11.00 really solve my problem or maybe their faultSmile
Enjoy iT