haripotter’s technorati

Just another WordPress.com weblog

How to determine if a test is executed from Quality center test lab

Hmmm. I’m back after a long time.  Okay.. lets get started.. How do we know if the test is being executed from a testset in testlab module of HP Quality center ?.. During development of the test script, we have to execute the code to see if the testscript is performing the test the way we wanted it to. We execute them directly from QTP IDE, even though we have connected to QC from QTP IDE. Let’s say one of your function does something that is dependent on the testscript name. Usually we use qcutil.CurrentTest.Name to determine the testscript name. But if we are not connected to QC, then this call will fail. In that situation, if we want to know if the test is executed from QC or from local system, we can use this function. Here’s the function. Enjoy.. In another post, I’ll provide the code for determining the testscript name irespective of whether QTP is connected to QC or not.



Public function IsExecutedFromQC()
 Dim CurrentTSTest
 if qcutil.IsConnected then
  Reporter.ReportEvent micPass,"Connected to QC", "Connected to Quality Center Server: " & qcutil.QCConnection.ServerName & vbcrlf & _
  "Project : " & qcutil.QCConnection.ProjectName & vbcrlf & " Domain : " & qcutil.QCConnection.DomainName
  Set CurrentTSTest = qcutil.CurrentTestSetTest
  if CurrentTSTest is Nothing then
   Reporter.ReportEvent micFail,"IsExecutedFromQC", "QTP is connected to quality center server. But the test is **not** executed from a Testlab in QC"
   IsExecutedFromQC = FALSE
  else
   Reporter.ReportEvent micPass,"IsExecutedFromQC", "The test is executed from a Testlab in QC"
   IsExecutedFromQC = TRUE
  end if
 else
  Reporter.ReportEvent micDone,"IsExecutedFromQC", "QTP is not connected to quality center server"
  IsExecutedFromQC = FALSE
 end if 
   
End Function

April 2, 2009 - Posted by haripotter | HP Quality Center and QTP | | No Comments Yet

No comments yet.

Leave a comment