WS API: how to filter Test Cases by Iteration
search cancel

WS API: how to filter Test Cases by Iteration

book

Article ID: 57618

calendar_today

Updated On:

Products

Rally On-Premise Rally SaaS

Issue/Introduction

WSAPI: how to filter Test Cases by Iteration?

 

Resolution

Object Model

See WS API documentation for the object model.
TestCase object does not have Iteration (and Release) attributes, hence it cannot be directly queried by a timebox.
Generally, Test Cases are scheduled for iteration indirectly via Test Sets when they are added to a TestSet that is scheduled for an iteration. 
There are two attributes on TestCase object that are relevant to this topic: TestSets attribute and WorkProduct attribute, since both provide an indirect link from a TestCase to Iteration.
TestSets attribute on TestCase is a reference to a collection of TestSets to which TestCase belongs.
WorkProduct attribute on TestCase is a reference to an Artifact type from which HierarchicalRequirement (a.k.a User Story) or Defect objects inherit. However, since WorkProduct attribute points to an abstract Artifact type that itself does not have Iteration attribute this connection does not help when constructing a query intended to return Test Cases related to an Iteration.
There is TestCases collection on HierarchicalRequirement (a.k.a User Story) object. It is possible to filter a User Stories by? Iteration and fetch TestCases collection on the story.

The important factor to consider is how your TestCases are related to Iterations. Are they scheduled via TestSets? Or are they linked to User Stories, which are scheduled for iterations?

Example used in this article:
Two stories and a test set are scheduled for an iteration. Iteration Status page shows that both stories have associated test cases, and the test set also has two different test cases.

 

Query TestCases by TestSets when TestSets are filtered by Iteration

In WS API interactive document a TestCase query can be constructed following this syntax: (TestSets.Iteration = /iteration/<ITERATION_OID>).

Here is a direct endpoint that can be pasted in the address bar of the browser that uses the same query:

https://rally1.rallydev.com/slm/webservice/v2.0/testcase?workspace=https://rally1.rallydev.com/slm/webservice/v2.0/workspace/<WORKSPACE-OID>&query=(TestSets.Iteration = /iteration/<ITERATION_OID>)

NOTE: General principals of constructing WS API queries is outside of the scope of this article. 

The same result can be achieved adding a Custom List app from AppCatalog to the Dashboard or any custom page in CA Agile Central.

Steps below assume that we already added a Custom List to your page and we are ready to specify the settings.

1. Set Type to Test Set and click Save to close Settings dialog.


2. Set a filter to limit TestSets by Iteration:

 

Note that Filters picker does not have to be used: the same result can be achieved by typing the query that we used in WS API?(TestSets.Iteration = /iteration/<ITERATION_OID>) in the "Query" box of Settings dialog.

3. The Custom List of TestSets loads. Expand TestSet to see TestCases under it. Columns can be added or removed using the Column picker on the right of the "Filter by Owner" dropdown.

 

Query Test Cases from TestCases collection on a User Story filtered by Iteration

In the previous example we tried to traverse from TestCase to WorkProduct filtered by Iteration, and it did not work since WorkProduct (being of type Artifact) cannot be filtered by Iteration. In this example we will traverse from a User Story filtered by Iteration to TestCases collection.

Here is an example of an endpoint that fetches TestCases collection on User Stories and summarizes it by FormattedID and LastVerdict attributes of TestCase object. User Stories are filtered by iteration.
Fore details on how to construct a query that summarizes a collection see
WS API Collection Summaries article. There is a section in the article that deals with TestCases collection on User Story object.

https://rally1.rallydev.com/slm/webservice/v2.0/hierarchicalrequirement?workspace=https://rally1.rallydev.com/slm/webservice/v2.0/workspace/<WORKSPACE_OID>&query=(Iteration = /iteration/<ITERATION_OID>)&fetch=TestCases:summary[FormattedID;LastVerdict]&pagesize=200

The same result can be achieved adding a Custom List app from AppCatalog to the Dashboard or any custom page in CA Agile Central.
Steps below assume that we already added a Custom List to your page and we are ready to specify the settings.

1. Set Type to User Story and click Save to close Settings dialog.

2. Set a filter to limit User Stories by Iteration:

3. The List loads. Expand user stories to see test cases:

TestCases attribute can also be added via the Column picker: