Wednesday, January 30, 2013

QTP Integration with Oracle DB

You can connect to Oracle database and execute SQL statements by following steps:

  • Oracle client has to be installed on QTP (or UFT) host.
  • Assuming the tnsnames.ora file contains the desired database information.
Using following two functions can help you to execute SQL queries.


Function executeQuery(p_db, p_sql)
 Reporter.ReportEvent micPass, "executeQuery", "The SQL query: '" &p_sql & "' is going to be executed on: '" & p_db & "'."
 If getVal(p_db)="N/A" Then
  Reporter.ReportEvent micFail,"executeQuery","DB connection information is not available."
  executeQuery = -1
  ExitAction
 End If
 
 Set localConn = CreateObject("ADODB.Connection")
 Set localRs = CreateObject("ADODB.Recordset")
 Set localErr = CreateObject("ADODB.Error")

 On Error Resume Next
 localConn.open getVal(p_db)
 
 Global_DBErr = ""
 For Each localErr In localConn.Errors
  if Err.Number<>0 then
   Global_DBErr = Global_DBErr & Err.Number & vbCr &  " " & Err.Description
   Reporter.ReportEvent micFail,"Step 1","DB connection failed: " & Global_DBErr
   ExitAction
  end if
 Next
 
 On Error Resume Next
 localRs.open p_sql, localConn
 
 For Each Local_Err In localConn.Errors
  if Err.Number<>0 then
   Global_DBErr = Global_DBErr & Err.Number & vbCr &  " " & Err.Description
   Reporter.ReportEvent micFail,"Step 1","SQL Execution Failed: " & Global_DBErr
   ExitAction
  End if
 Next
 
 if localRs.eof then
  v_retVal = -1
 else  
  v_retVal = localRs(0).value
 end if

 set localConn = Nothing
 set localRs = Nothing
 set localErr = Nothing

 Reporter.ReportEvent micPass, "executeQuery", "Query result: [" & v_retVal & "]"
 executeQuery = v_retVal
End Function


Function getVal(p_key)
 v_retVal = "N/A"
 Select Case p_key
  Case "DB1" v_retVal = "Provider=MSDAORA.1;Password=DB_PASWORD1;User ID=LOGIN_USER1;Data Source=DB1;Persist Security Info=True"
  Case "DB2" v_retVal = "Provider=MSDAORA.1;Password=DB_PASWORD2;User ID=LOGIN_USER2;Data Source=DB2;Persist Security Info=True"
 End Select
 getVal = v_retVal
End Function

How you make use of these functions is as following:

 v_sysdateFromDB = executeQuery(Parameter("p_db"), "select sysdate from dual")

Wednesday, January 23, 2013

How to restore a QC project that is bigger than 4GB

HP officially does not support importing qcp files for the projects whose size is bigger than 4GB and at the same time size of the qcp file must be smaller than 2GB. You probably going to get "Server disconnected while performing ImportProject action" error message while importing the project from siteadmin panel.
Detailed information can be found in this document (KM1025768).

Tuesday, January 22, 2013

How to make scheduled backup of a QC project

The Quality Center's site admin supports backing up and restoring the projects as following the below screenshot procedure.

Tuesday, November 13, 2012

A Workaround Solution For QC Reporting According To User Groups

Sometimes QC's group functionality for the users may not sufficient for reporting. For example you may want to report some user actions accoriding to their team/department/divison.

Monday, November 12, 2012

How to get testcase path from QC DB

Sometimes you may need to report testcases those are in a specific folder with some custom format. This can be done from the analysis view of the dashboard easily. But sometimes getting the testcases from the DB with some SQLs may be the way you might prefer.

Friday, September 21, 2012

Is Ajax TruClient a lifesaver?

Most of the time I prefer HTTP/HTML scripting protocol. Because it offers you to know all the details about requests and responses during replay and the actual load test.

Monday, July 23, 2012

VUGEN - QC Connectivity

As you know manual test cases are stored in the Quality Center (QC) application. There is no restriction about the Loadrunner script files.