Micro Focus QTP (UFT) Forums
PASS/FAIL in QTP - 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: PASS/FAIL in QTP (/Thread-PASS-FAIL-in-QTP)



PASS/FAIL in QTP - badri - 11-29-2014

Let me explain the problem using an example. Lets say I have to validate a login functionality in a web page. Login is success for "login" and "passwd123" user credentials and for rest throws error message.
In the script using Data Driven I try to login using various users. For a valid user, on login success I check the text and if exists I report a message with PASS else FAIL.

Now my question is when I manually execute this test case, when the valid user is allowed to login and for the rest it throws a message. I PASS this test case.

when I run this data driven script with same logic, the QTP summarized result shows FAILED though the script completed successfully.

what is the correct approach. How to go about handling PASS/FAIL in QTP script.


RE: PASS/FAIL in QTP - supputuri - 12-01-2014

Hi Badri,

Are you using the conditional statements and then using QTP Pass/Fail?

It should be some thing like
Code:
if (this error message display) then
    QTP pass
else
    QTP Fail
end if



RE: PASS/FAIL in QTP - badri - 12-02-2014

Thats fine..I am using the same way. But try to understand my question.

when i execute the testcase for various users(valid n invalid), the manual test case is PASS.
Similarly, when i run as automated, how should i handle the logic for PASS/FAIL.


RE: PASS/FAIL in QTP - kiranpol - 12-05-2014

Code:
'Valid user name and password
  username = "abc"
  password = "def"

Call Login("Valid",username,password)

'InValid user name and password
  username = "xyz"
  password = "pqr"

Call Login("InValid",username,password)

'Login Function
Function Login(strValidation,UN,PWD)

if strValidation = "Valid" then
   'code to validate successful login
elseif strValidation = "InValid" then
   'code to validate failure login
end if

End Function