Can I determine whether current component is execu

2019-07-10 16:46发布

问题:

Can I determine (programmatically) how my current business component scriptcode has been initiated?

It could be

  • standalone (using "Run" from UFT's toolbar while the component is open)
  • from a standalone test execution (using "Run" from UFT's toolbar while a test calling the component is open)
  • from a test lab execution (using "Run" or "Run all" button in the test set im ALM)?

Foggily related: Can I determine if current test execs from test lab or interactively from within QTP IDE?

回答1:

If the component is executed standalone, CreateObject ("QuickTest.Application").CurrentDocumentType returns "Business component".

If the component is executed from within a BPT (no matter if the BPT is executed interactively, or from within a test set) CurrentDocumentType returns "Test".

Combined with the setting brought to light in the related question (and answer), this answers the question. It's as simple as that.