ALM/QC – How to Update a Test Plan Field using OTA

Software Testing Published on:

Is it possible to use OTA to update a Test Plan Field in ALM/QC?

Since writing my posts “How to Update a Defect using OTA” and “How to Update a Test Set Field Using OTA” I've received a few emails inquiring if it's possible to also update information for an ALM Test Plan using HP's Open Test Architecture (OTA).

The quick answer is “Yes” but rather than answer each one individual, I thought it would be better to frame my replay in the form of a quick post.

How to get the QC/ALM field name

In order to update a field in ALM using OTA you will need to know the backend name that ALM assigns to the field. This name is normally different than the label name that you might see in the ALM Test Lab section.

If you don't know what the actual field names are, you can easily find them by going into QC's Tools>Customize.

In the Project Customization section and go into the “Project Entities” section.


Under the Project Entities Tree view click expand Defect and click on your System Folder or User Fields. Clicking on a field will reveal the field name that you will need to use.

For this example I want to find the System Field > Status and get the name value for it (TS_STATUS)

QTP OTA Code to Update a Test Plan Field in an ALM/QC Test Lab

The following example updates the ‘Test Plan' that has the ‘Test Set ID' of 6 and changes the ‘Status' field to Ready.


The code is pretty straight forward and uses the OTA's TestFactory object to accomplish our goal.

  • Creating an instance of the TestFactory object allows us to access all the services needed to manage tests.
  • Next you set the Filter property to set the ID for the test set that you want to update.
  • Finally use the TestFactory's NewList method to create a list of object that matches your specified filter.
  • Make sure to use the Post method to actually write the changed values to your ALM database
'=========================================
set tdc = createobject("TDApiOle80.TDConnection")
tdc.InitConnectionEx "http://yourURL/qcbin"
tdc.Login "yourName","yourPassword"
tdc.Connect "yourDomain","yourProject"
'=========================================
testPlanID = 6
Set TestList = tdc.TestFactory
Set TestPlanFilter = TestList.Filter
TestPlanFilter.Filter("TS_STATUS") = testPlanID

Set TestPlanList = TestList.NewList("")
Set myTestPlan = TestPlanList.Item(testPlanID)
myTestPlan.Field("TS_STATUS") = "Ready"
myTestPlan.Post

Set TestPlanFilter = Nothing
Set myTestPlan = Nothing
Set TestList = Nothing
Set TestPlanFilter = Nothing

How Update All Tests

There might be times when you need to update the same field for all the tests in your test plan. To update the same field for all your tests you could create code that loops thru all the tests:

'=========================================
set tdc = createobject("TDApiOle80.TDConnection")
tdc.InitConnectionEx "http://yourURL/qcbin"
tdc.Login "yourName","yourPassword"
tdc.Connect "yourDomain","yourProject"
'=========================================
Set TestList = tdc.TestFactory
Set TestPlanFilter = TestList.Filter
Set TestPlanList = TestList.NewList("")
For each tpTest in TestPlanList
 Set myTestPlan = TestPlanList.Item(tpTest.ID)
 myTestPlan.Field("TS_STATUS") = "Ready"
 myTestPlan.Post
Next 
Set TestPlanFilter = Nothing
Set myTestPlan = Nothing
Set TestList = Nothing
Set TestPlanFilter = Nothing

How to run the code

To run the defect code you can either place it in QTP and run as a script or place the code in a text file and save as a .VBS vbscript file.

Good Luck!

11 responses to “ALM/QC – How to Update a Test Plan Field using OTA”

  1. I don’t see the “Project Entities” section within Tools > Customize… Do you need special permissions to see this section in QC?

    I’m a contractor working for a city agency and don’t have unlimited access without going through lots of hoops. I’m looking to delete steps in order to upload updated steps from excel (deleting all steps in qc directly takes time over hundreds of Test Sets, and deleting the actual Test Set itself deletes any runs already executed in Test Lab).

  2. Hi,

    Can you please post the project entities means the inner field name i am working on a tool.I dont have access to see the entities.

    Thanks.

  3. I have two folders in test plan. I want to ipdate two fields value in first folder test cases .
    Pls give me sample code

  4. Hi,

    I used your code to update Test Plan but is not updating the field, i received not error just no update in the test plan.

    thanks,
    Angel

  5. Hi Joe,

    my requirement in ALM is to check in the checked out entities once user clicks on a button,
    1. If users select an entity and clicks on the created button, that entity should be check in.
    2. If user select a particular folder, and clicks on the button, all the entities which are checked out should be checked in that folder.

    Please post the code if it is possible.

    regards,
    Kiran Kasu

  6. My requirement is to upload multiple screenshots in ALM and attach them to cases in Test Lab. Can you please provide me a code for same

  7. Hi,
    Do you know how to update fields from “Test Script” tab in Test in Test Plan in ALM?
    I have to update field: “DLL Path” for many tests but it is hard to find this field…
    BR,
    Adam

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.