Wednesday, 5 March 2014

QC 11.0

I. QTP Integration HP ALM 11 or Quality Center is used as a test management tool in which we can store tests, function Libraries, test data,... thumbnail 1 summary

I. QTP Integration


HP ALM 11 or Quality Center is used as a test management tool in which we can store tests, function Libraries, test data, object repository, recovery scenario and much more. Below are some of the features in QTP required to connect to Quality Center and various options in QTP regarding QTP-QC Integration


Integration between QC and QTP:

QTP can connect to a project stored in ALM through VBScript Code or through QTP IDE as explained below:

1. How to integrate QTP 11 with Quality Center/ALM using AOM Script?


Through Code

Below code creates a connection to QC. This will validate if a connection to QC already exists and in case not connected than connects to the required project in QC

Public Functionfunc_ConnectQCQTP(QCurl,Domain,ProjectName,UserName,Password)
Set qtApp = CreateObject("QuickTest.Application") 
  If  qtApp.launched <> True then 
      qtApp.Launch 
  End If
  qtApp.Visible = "true"
  If Not qtApp.TDConnection.IsConnected Then
      qtApp.TDConnection.Connect QCurl,Domain,ProjectName,UserName,Password,False
  End If
Set qtApp = nothing
End Function

2. How to integrate QTP 11 with Quality Center/ALM with Tools Options?


Through QTP Interface

Go to File>ALM/QC Connection as shown below and create the connection.

step 1:

Step 2:





















User is allowed options to reconnect to the QC Server, and authenticate on start up and login to project automatically once QTP is launched.

Version Control in QC

In case of test stored in QC,version controlling the test script is very useful,so that test can be open by one user at a time and previous versions of test are available and can revert to previous version in case of issues. In case of version control, a test will open in read only mode and changes in script can be done only post checking out the script, and once changes are incorporated, changes should be checked in.

Step 3:












Ignoring QC browser

In case of descriptive programming, there can be issues in object identification in case of QC browser if not ignored. QC Browser can be ignored making following settings:
Go to tools>Options>Web and select checkbox to ignore QC browser as shown below

Step 4:










Execution of Test from Quality Center Test Set

Below settings is required to run tests from Quality Center Test Set in QTP.

Step 5:
II. Store the Automation Test Cases in QC

1. How to store the Automation Test Cases in QC /ALM?


III. Run the Automation Test Cases in QC

1. How to run the specific QTP Tests from Test Set in QC /ALM using VB Script?

Below code will execute tests in a test set in QC based on name of the test set. The code can run all the scripts in test set, only passed test script, only failed test script. This can be manipulated further based on requirement. Also an html file with test status will be displayed once test set execution is completed.

UserName = InputBox("Enter the user name for QC Login", "QC UserName")
Password  = InputBox("Enter the password for QC Login", "QC Password")

strExecFlag = InputBox("Enter the option for test execution" & vbcrlf & "Valid Values - P, A,F" & vbcrlf & "A: Run All test Scripts"& vbcrlf & "F: ExecuTe script not passed Only"& vbcrlf & "P: Execute Passed Test Scripts","Test Execution Option")

'Return the TDConnection object.
Set QCConnection = CreateObject("TDApiOle80.TDConnection")
QCConnection.InitConnectionEx QCurl
QCConnection.login UserName, Password
QCConnection.Connect DomainName, ProjectName
Set TSetFact = QCConnection.TestSetFactory 
Set tsTreeMgr = QCConnection.TestSetTreeManager 

Dim qtApp 'As QuickTest.Application ' Declare the Application object variable 
Dim qtLibraries 'As QuickTest.TestLibraries ' Declare a test's libraries collection variable 

Set tsFolder = tsTreeMgr.NodeByPath(<QC Test Set Path>)'' test set starts with "Root"

Set tsList = tsFolder.FindTestSets(<TestSetName>) 'Testset name
strTable = ""

Set theTestSet = tsList.Item(1)
For Testset_Count=1 to tsList.Count
 Set theTestSet = tsList.Item(Testset_Count) 
 Set TSTestFact = theTestSet.TSTestFactory
 TSName = theTestSet.Name
 Set TestSetTestsList = TSTestFact.NewList("") 
 For Each theTSTest In TestSetTestsList 
  TestName = theTSTest.Test.Name   
  TestScript = <Test Script path in QC> & TestName   
  TestStatus = theTSTest.Status

  If ((TestStatus ="Passed" and ucase(strExecFlag) = "P") OR (TestStatus <>"Passed" and ucase(strExecFlag) = "F") or (ucase(strExecFlag) = "A")) Then

  Set qtApp = CreateObject("QuickTest.Application") 
 
If  qtApp.launched <> True then 
   qtApp.Launch 
  End If

  qtApp.Visible = "true"

  If Not qtApp.TDConnection.IsConnected Then
   qtApp.TDConnection.Connect QCurl,DomainName,ProjectName,UserName,Password,False
  End If

  ' Create the Application object
  qtApp.Open TestScript, True   ' Open the test in read-only mode
  Set qtTest = qtApp.Test
  Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions") ' Create the Run Results Options object 

  '   New Run Results in Quality Center option
  qtResultsOpt.TDTestInstance = 1

  qtResultsOpt.TDRunName= "Run_" & Month(Now) & "-" & Day(Now) & "_" & Hour(Now) & "-" & Minute(Now) & "-" & Second(Now)

  qtResultsOpt.TDTestSet = TestSetPath' Path to the Test Set where we should save the results

  Set fso=createobject("Scripting.FileSystemObject")
  If fso.FolderExists("C:\Res1") Then 
   fso.DeleteFolder("C:\Res1")
  End If
  qtResultsOpt.ResultsLocation = "C:\Res1"
  qtTest.Run qtResultsOpt,True
  TestStatus = qtTest.LastRunResults.Status
  qtTest.Close
  qtApp.quit
  Set qtApp = Nothing
 
  strTable = strTable & "<tr><td>"&TestName&"</td><td>"&TestStatus&"</td></tr>"
  End If
 Next
Next

Set objFSO = CreateObject("scripting.filesystemObject")

If (objFSO.FolderExists("c:\Temp") = False) Then
 objFSO.CreateFolder("c:\Temp")
End If

strTable = "<html><h1>Test Results<h1><table border =""""2""""<tr><td>TestCaseName</td><td>Test Execution Status</td></tr>" & strTable &"</table></html>"

Set objFl = objFSO.CreateTextFile("c:\Temp\Test.html")
objFl.Write strTable
Set objFl = nothing
CreateObject("WScript.Shell").Run "c:\Temp\Test.html" 

2. How to run the Automation Test Cases in QC /ALM using QTP Particular Script?

No comments

Post a Comment