QC/ALM and accessing Test Instance Step Values with QTP (3918 Views)
Reply
Frequent Advisor
Nick_NIPR
Posts: 41
Registered: ‎10-05-2012
Message 1 of 7 (3,918 Views)
Accepted Solution

QC/ALM and accessing Test Instance Step Values with QTP

[ Edited ]

 

Hi,

 

 

I would think this is a pretty logical thing to do if you are using QC and QTP but in all my searching I cannot find an example of someone doing it.

 

We have an Integration Test Instance and run, that has test values in the run_steps that we want to use in QTP to run scripts with.  My team and I unfortunately are not sure the linking reference between the Test Instance and where it appears either the Test Plan Module or the Manual Runner are getting the Steps from.  How do we make this link?

 

We can find the path to the test instance, but need to connect the Test ID and the linked run steps that have the value.  I don't need all the code, just help with connecting the final steps.

 

I can make the connection to the TC_TEST_INSTANCE but how do I add the correlation to the TS_NAME and then the connected steps in that run?

Test Instance.png

 

 

 

Honored Contributor
Trudy Claspill
Posts: 3,715
Registered: ‎09-09-2010
Message 2 of 7 (3,904 Views)

Re: QC/ALM and accessing Test Instance Step Values with QTP

A Test Instance is a special record linking a Test Case from the Test Plan to a Test Set in the Test Lab.

When you run a Test Instance that spawns a new record - a Run record, which summarized information about that execution of that Test Instance.

In the Manual Runner when you then click Begin Run, in real time the application follows the link from the Run back to the Test Instance to find the source Test Case. It then follows the link from the Test Case to the Design Steps records to find the steps for the test case. It then makes a copy of each Design Step in the STEPS table (executed Design Steps). STEPS are linked to a Run record. STEPS don't exist until a Test Instance has been Run.

You may want to study the Database Reference documentation to better understand the relationships between the entities.

Accessing the data from QTP depends on the context. Is QTP trying to obtain this info for a Test it is current running, or for a test that has already been run? In either case, you will use the QCUtil object in QTP to connect to QC to get at the data. The QCUtil object gives you access to the entire Open Test Architecture API for QC. Through that you can get to pretty much all the data in a project. There's a reference document in the QC application for the API also that you'll probably need to study.
[If this post solves or helps solve your issue, mark the thread as solved and give KUDOS to the author for their assistance.]

(Opinions expressed in my postings are mine alone, and do not reflect the opinions of my employer.No warranties express or implied for any solution/suggestion posted.)
Frequent Advisor
Nick_NIPR
Posts: 41
Registered: ‎10-05-2012
Message 3 of 7 (3,903 Views)

Re: QC/ALM and accessing Test Instance Step Values with QTP

Hi Trudy,

 

Thanks, that's exactly what I'm talking about.

 

I figured the run had to be pulling back the design steps from the linked test since those fields don't exist in the manual_run table.  

 

This would be a new QTP test that is getting information from a previous QC manual test.  Would it be possible, to get the run_id from the previous QC manual test (run record) and link to those executed Design Steps?

 

If so, is it really feasible and efficient to try to get this data that way?  

 

Some more context, currently we're running an Excel report that gets all key data from a specific target_cycle and then using the datatable to create the QTP tests.   However, I assumed it would be more efficient just to get the data from the executed design steps directly by going through the test lab, but ran into this issue on how to make the association.

Honored Contributor
Trudy Claspill
Posts: 3,715
Registered: ‎09-09-2010
Message 4 of 7 (3,888 Views)

Re: QC/ALM and accessing Test Instance Step Values with QTP

It is possible to do this using the QCUtil object and accessing the full OTA API functionality to find and retrieve the records that you want. The QTP documentation will tell you about accessing the QCUtil object and using it to get to the full OTA API. You'll also have to look at the OTA API documentation in ALM/QC itself for the details of how to use the functionality in the API.

Alternately, if you already have a query in an Excel report that extracts the data, you could execute that query through your QTP script. You could write code to execute the query using the Command object of a TDConnection (available as part of the OTA API), if your system allows you to use the Command object. You could probably also script execution of the query directly using ODBC or something like it, rather than the OTA API.

Without putting more effort into analyzing the details of what you're doing, I can't really say if that is the most efficient way to go about this.

In my experience, running queries to extract information is often faster than trying to get the same information by using the OTA API entity Factories. I've not done a comparison between running a query using the Command object vs. directly using query running technology. I've done these sorts of things through custom VB program, not QTP, so I don't know how that efficiency compares either.
[If this post solves or helps solve your issue, mark the thread as solved and give KUDOS to the author for their assistance.]

(Opinions expressed in my postings are mine alone, and do not reflect the opinions of my employer.No warranties express or implied for any solution/suggestion posted.)
Frequent Advisor
Nick_NIPR
Posts: 41
Registered: ‎10-05-2012
Message 5 of 7 (3,876 Views)

Re: QC/ALM and accessing Test Instance Step Values with QTP

Thanks Trudy,

 

We successfully made our connection through QTP and the api to the last run and run_steps that we needed. 

Occasional Visitor
Sutha
Posts: 1
Registered: ‎10-05-2013
Message 6 of 7 (3,798 Views)

Re: QC/ALM and accessing Test Instance Step Values with QTP

Hi 

 

Is there a sample code, i am trying to do the same, i want to read the test steps data from QC and run it through QTP scripts.

Example read the description, expected result etc from QC test step.

Advisor
Pandharinathj
Posts: 7
Registered: ‎03-03-2014
Message 7 of 7 (2,498 Views)

Re: QC/ALM and accessing Test Instance Step Values with QTP

Sub BeginTest()
     ' copy design steps to current run
 CopyDesingSteps 

EndSub

'=============================================================================================
'@purpose- this function will copy design steps from 'design steps' tab to current run of test in QC
'make sure qtp and qc connection has been established before runnning the test
'=============================================================================================
Function CopyDesingSteps()
    Onerrorresumenext
    Dim otest
    if QCUtil.IsConnected =Falsethen
    msgbox"Please establish connection to ALM first."
        'ExitAction
        Exitfunction
    
    Endif
    set CurrentRun = QCUtil.CurrentRun
    
    ' copy design steps to current run

      CurrentRun.CopyDesignSteps

     GetDesignSteps  CurrentRun

    intTotalNumberOfUpdatedSteps=0
    
EndFunction



'=============================================================================================
'@ purpose- this function will retrive  the list of steps of current run in to runStepList
'=============================================================================================
Function GetDesignSteps(CurrentRun)
    'On error resume next
    Dim intStepcount
    Set runStepF = CurrentRun.StepFactory

    Set runStepList = runStepF.NewList("")
        intTotalNumberOfSteps=runStepList.Count
    For intStepcount = 1To runStepList.Count
        runStepList.Item(intStepcount).Field("ST_STATUS") ="Not Completed"
        runStepList.Item(intStepcount).Field("ST_ACTUAL") ="Not Completed"
        runStepList.Post
        
    Next
    
    Set runStepF = nothing               
EndFunction
'=============================================================================================
'@purpose- This function will update specified step with status and actual in test run result
'=============================================================================================
Function UpdateStep(byval stepID,byval strStatus,byval strData)
    'On error resume next

        If strStatus = TrueThen
            strStatus="Passed"
        '
        else
        strStatus="Failed"
        
        EndIf
        ' update step status and step actuals
        runStepList.Item(stepID).Field("ST_STATUS") =strStatus
        runStepList.Item(stepID).Field("ST_ACTUAL") =strData
        runStepList.Post
        
EndFunction

Sub EndTest()
    CurrentRun.Post
    Set runStepList= nothing
    Set Currentrun = nothing

endSub

The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.