2

What is the most efficient way to check if the current QTP test execution is interactive, i.e. not part of a QC test set execution launched from the QC test lab?

Do you guys know a cool way? WR used to have a batch run flag which reliably was cleared for all executions from within the IDE. Maybe QTP has something like this, and I overlooked it?

First, I thought about looking at the OnError property:

Set qtApp = getObject("","QuickTest.Application")

qtApp.Test.Settings.Run.OnError now returns one of these possible values: "Dialog", "NextIteration", "Stop" or "NextStep".

This would allow me to look at the OnError setting, which probably is <> "Dialog" and <> "Stop" when execution is part of a test set, but:

  • I managed to avoid the automation interface in all my QTP tests, this would be my first exception (earlier QTP versions got confused and launched a second QTP instance, creating lots of problems...)
  • A tester might do an "interactive" run from within the QTP IDE with this setting set to "NextStep" or "NextIteration", which I then would misinterpret in my code.
  • It does not work, even if dialogs are not coming up (due to execution from a QC test set), the value returned is "Dialog". DOH!
TylerH
  • 20,799
  • 66
  • 75
  • 101
TheBlastOne
  • 4,291
  • 3
  • 38
  • 72

2 Answers2

2

No need to go to the automation object, it is exposed in the Setting object.

If Setting("IsInTestDirectorTest") Then
    Print "Run from QC"
Else
    Print "Not run from QC"
End If     

Note that TestDirector (TD) is the historical name of QualityCenter (QC).

Motti
  • 110,860
  • 49
  • 189
  • 262
  • Doh. That works perfectly. Where is this documented? If it is not documented, how do you know about it? – TheBlastOne Nov 15 '10 at 10:38
  • Even google has 0 exact hits for the string IsInTestDirectorTest. WTF? – TheBlastOne Nov 15 '10 at 10:39
  • @TheBlastOne, I could tell you but then I'd have to recruit you... I'm not sure if this is a supported feature [anyway soon Google should have at least one hit for `IsInTestDirectorTest` :o)]. – Motti Nov 15 '10 at 11:04
  • Got it, thanx. Duke Nukem would say: "Hehehe, what a mess." – TheBlastOne Nov 15 '10 at 11:24
  • Addendum: Setting ("IsInTestDirectorTest") returns Empty if execution is not from within a TD/QC/ALM test set, NOT false. (Since empty <> true, this does not matter in the code shown.) Obviously, the setting only exists if... – TheBlastOne Jun 26 '13 at 07:03
  • *Update* This setting still works with UFT. However, as soon as the UFT instance has executed one test from ALM, the setting always returns 0 (not empty). So this works only if you uncheck "Keep UFT open after a test lab run session ends" in the UFT remote agent settings. Not sure if this should be added to the answer. @Motti I´d vote for doing so. – TheBlastOne Jan 13 '16 at 06:20
0

It might be an option to use

Public Function IsTestSetRun ()
    Dim Result: Result=false
    If not QCUtil is Nothing then
        If not QCUtil.CurrentTestSetTest is Nothing then
            Result=true
        End If
    End If
    IsTestSetRun=Result
End Function

which is based on QCUtil.CurrentTestSetTest. Unfortunately, it returns true if you run a GUI test interactively, so it is not really a complete solution.

But since the other option does not work with BPT components, I am now using this option.

TheBlastOne
  • 4,291
  • 3
  • 38
  • 72