Can I determine if current test execs from test la

2020-03-06 03:47发布

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!

2条回答
地球回转人心会变
2楼-- · 2020-03-06 03:57

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.

查看更多
成全新的幸福
3楼-- · 2020-03-06 04:21

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).

查看更多
登录 后发表回答