'LoadRunner - exiting login transaction on failure and perform log off

I'm running a LoadRunner test , upon user failure at login /even at any other transaction it has to fail and execute log off portion of the script.

Note: I have put text check and with textcheck count if the transaction fails( using if condition I have handled it) it then ends transaction with fail status .I would need solution to perform log off also at the point where the if condition fails.

Can anyone share me with an example to execute log off when textcheck fails.



Solution 1:[1]

Depends upon your language choice.

Assuming you have the default language of C with your HTTP virtual user, then simply implement a logout function which contains your logout code. Call that function upon failure of your condition. A "return 1;" inside of that if/then conditional will also start a new iteration immediately. "return 0;" goes to a new iteration with respected pacing. "return -1;" kills the virtual user altogether.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 James Pulley