WS API: how to filter Test Cases by Iteration

Document ID : KB000057618
Last Modified Date : 14/02/2018
Show Technical Document Details

Issue

WS API: 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. See Test Sets help page in CA Agile Central Help.
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.

User-added image

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 ObjectID>).

User-added image

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/12352608129&query=(TestSets.Iteration = /iteration/41089395114)

NOTE: General principals of constructing WS API queries is outside of the scope of this article. See General Query Examples article in CA Agile Central Help.

The same result can be achieved adding a Custom List app from AppCatalog to the Dashboard or any custom page in CA Agile Central. See Customize your Dashboard article in CA Agile Central Help for details on how to add an app to a Dashboard or any custom page.

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.

User-added image

2. Set a filter to limit TestSets by Iteration:

User-added image
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 ObjectID>) 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.

User-added image

Query TestCases by WorkProduct when WorkProduct is filtered by Iteration
NOTE: this will not work but since it is commonly attempted it deserves to be mentioned.


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.

This query:

https://rally1.rallydev.com/slm/webservice/v2.0/testcase?workspace=https://rally1.rallydev.com/slm/webservice/v2.0/workspace/12352608129&query=(WorkProduct.Iteration = /iteration/41089395114)

returns:

Errors: [
"Could not parse: Attribute "Iteration" on type Artifact is not allowed in query expressions."
],




User-added image

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/12352608129&query=(Iteration = /iteration/40695561076)&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.

User-added image

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

User-added image
3. The List loads. Expand user stories to see test cases:

User-added image

TestCases attribute can also be added via the Column picker:

User-added image

User-added image
?