msacks
msacks

Reputation: 41

How to tell when a script is running from ALM or directly from UFT?

I have a script that prompts a user for input data via a MsgBox. I'd like to run the script remotely from ALM test lab and modify it so that these prompts don't come up when I'm running remotely but do when I'm running directly from UFT.

How can I distinguish whether the script is being run from an ALM test lab or directly from UFT? There is an environment variable called ControllerHostName that I thought would be set to the remote host but, when I run remotely, this variable is left blank. LocalHostName only indicates the host on which the script is running but not the host from which ALM is being run.

Upvotes: 2

Views: 203

Answers (1)

TheBlastOne
TheBlastOne

Reputation: 4320

There used to be ways, one of which you can see in Can I determine whether current component is executed from ALM's test lab, or interactively?, but considering all the ALM and UFT versions, starting with UFT 15, the last remaining options ceased to work property, which is why we built down to a solution that checks if there is a test set associated with the current run.

For what we call "interactive runs", i.e. F5 in UFT, we use "temp results". In the library code, a function queries the associated test set. If there is none, it is an interactive run, otherwise it is an unattended (possibly scheduled) ALM-initiated run.

So our logic now is: If QCUtil.CurrentTestSetTest does not generated an RTE and does not return nothing, it is an ALM test set run, otherwise it is not.

Unfortunately, you cannot query QCUtil.CurrentTestSetTest during library initialization. That would be too easy, it seems. Libs must do their startup first. Also, QCUtil.CurrentTestSetTest is quite costly, which means it might make sense to store it´s value in a global variable and initialize that variable "late enough, and soon enough", and only once, i.e. lazy-ly.

It´s as bad as it is ;\

Upvotes: 0

Related Questions