list-test-cycle
List qTest test cycles by project ID. Filter by name, parent cycle, or single cycle ID for targeted results.
Instructions
Test Execution — list qTest test cycles. Omit all optional args for root-level listing, provide id for a single cycle, or provide name to filter by name (case-insensitive exact match)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | Numeric project ID as string | |
| id | No | Test cycle ID; returns a single cycle | |
| name | No | Filter cycles by name (case-insensitive exact match) | |
| parentId | No | List child cycles of this parent test cycle ID |
Implementation Reference
- Main handler function that lists test cycles. Accepts projectId (required), id, name, and parentId (optional). If id is provided, fetches a single cycle and its children tree. Otherwise, fetches all cycles (optionally filtered by parentId) and optionally filters by name (case-insensitive).
export async function listTestCycles( args: ListTestCyclesArgs ): Promise<QTestTestCycle | QTestTestCycle[]> { const { projectId, id, name, parentId } = args if (id !== undefined) { const raw = await qtestFetch(config, projectId, `/test-cycles/${id}`, 'GET') return fetchCycleTree(projectId, raw as QTestTestCycle) } const endpoint = parentId !== undefined ? `/test-cycles?parentId=${parentId}&parentType=test-cycle` : '/test-cycles' const raw = await qtestFetch(config, projectId, endpoint, 'GET') const all = extractArray<QTestTestCycle>(raw) if (name !== undefined) { const lower = name.toLowerCase() return all.filter((c) => c.name.toLowerCase() === lower) } return all } - Recursive helper function that fetches and attaches child cycles to a given test cycle, building a full hierarchy tree.
async function fetchCycleTree(projectId: string, cycle: QTestTestCycle): Promise<QTestTestCycle> { const childrenRaw = await qtestFetch( config, projectId, `/test-cycles?parentId=${cycle.id}&parentType=test-cycle`, 'GET' ) const children = extractArray<QTestTestCycle>(childrenRaw) if (children.length > 0) { const childTrees: QTestTestCycle[] = [] for (const child of children) { childTrees.push(await fetchCycleTree(projectId, child)) } cycle.children = childTrees } return cycle } - TypeScript interface defining the input arguments for listTestCycles: projectId (string), id (optional number), name (optional string), parentId (optional number).
export interface ListTestCyclesArgs { projectId: string id?: number name?: string parentId?: number }