You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何从HP ALM中获取所有测试用例包含的操作名称?

Hey there! Let's figure out how to extract all operation names (step names) from your massive HP ALM test cases. I’ve got three solid methods tailored to different technical skill levels:

Method 1: Built-in Excel Export (No Coding Required)

This is the easiest option if you prefer a point-and-click approach:

  • Log into HP ALM and navigate to the Test Plan module. Select the folder containing your test cases (or select all test cases if needed).
  • Go to the top menu bar: Tools > Export > Excel
  • In the export wizard, make sure to check the Test Steps (or just Steps, depending on your ALM version) field group. This will include each step's operation name (usually labeled "Step Name" or "Description").
  • Once exported to Excel, you can clean up the data: use the UNIQUE() function (Excel 365/2021+) to pull out all distinct operation names, or use filters to sort and deduplicate manually.
Method 2: HP ALM REST API (For Technical Users/Automation)

If you need to automate this process or handle extremely large datasets, the REST API is your friend:

  1. Authenticate: First, send a POST request to your ALM server's authentication endpoint:
    POST http://<your-alm-server>/qcbin/rest/authentication-point/authenticate
    
    Include your ALM username and password in the request headers or as form data.
  2. Fetch Test Cases: Send a GET request to retrieve all manual test cases (adjust the query if you need other test types):
    GET http://<your-alm-server>/qcbin/rest/domains/<your-domain>/projects/<your-project>/tests?query={{test-type["Manual"]}}
    
  3. Extract Steps: For each test case, send a GET request to fetch its steps using the test ID:
    GET http://<your-alm-server>/qcbin/rest/domains/<your-domain>/projects/<your-project>/tests/<test-id>/steps
    
  4. Collect Operation Names: Parse the JSON response from each steps request, extract the name or description field (depending on your ALM setup), and add them to a set to automatically deduplicate.

Here’s a quick Python snippet to illustrate the workflow:

import requests

# Configure your ALM details
ALM_BASE_URL = "http://your-alm-server/qcbin/rest/domains/your-domain/projects/your-project"
USERNAME = "your-username"
PASSWORD = "your-password"

# Set up session and authenticate
session = requests.Session()
session.post(f"{ALM_BASE_URL}/authentication-point/authenticate", auth=(USERNAME, PASSWORD))

# Fetch all manual tests
tests_response = session.get(f"{ALM_BASE_URL}/tests?query={{test-type[\"Manual\"]}}")
tests = tests_response.json()["entities"]

# Collect unique operation names
unique_operations = set()
for test in tests:
    test_id = test["Fields"]["Field"][0]["value"]  # Adjust index based on your ALM JSON structure
    steps_response = session.get(f"{ALM_BASE_URL}/tests/{test_id}/steps")
    steps = steps_response.json()["entities"]
    for step in steps:
        # Replace with the correct field index for your step name
        step_name = step["Fields"]["Field"][3]["value"]
        unique_operations.add(step_name)

# Print results
print("Unique Operation Names:")
for op in unique_operations:
    print(op)

# Logout
session.post(f"{ALM_BASE_URL}/authentication-point/logout")

Note: The JSON field indices might vary between ALM versions—use Postman or a similar tool to inspect the API response structure first.

Method 3: OQC Script (Advanced Automation)

If you have access to Open Quality Center (OQC) tools, you can use VBScript or Java to directly interact with ALM's COM interface:
Here’s a VBScript example to extract step names:

' Initialize ALM connection
Set tdConn = CreateObject("TDApiOle80.TDConnection")
tdConn.InitConnectionEx "http://your-alm-server/qcbin"
tdConn.Login "your-username", "your-password"
tdConn.Connect "your-domain", "your-project"

' Create a dictionary to track unique operations
Set uniqueOps = CreateObject("Scripting.Dictionary")

' Fetch all manual tests
Set testFactory = tdConn.TestFactory
Set allTests = testFactory.NewList("")

For Each test In allTests
    If test.Type = "MANUAL" Then
        ' Get steps for the test
        Set stepFactory = test.TestStepFactory
        Set allSteps = stepFactory.NewList("")
        For Each step In allSteps
            If Not uniqueOps.Exists(step.StepName) Then
                uniqueOps.Add step.StepName, 1
            End If
        Next
    End If
Next

' Output results
WScript.Echo "Unique Operation Names:"
For Each opName In uniqueOps.Keys
    WScript.Echo opName
Next

' Clean up connection
tdConn.Logout
tdConn.ReleaseConnection

内容的提问来源于stack exchange,提问作者James

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 08:40:02