TestRunItems_LoadByCriteria Operation

Applies to QAComplete 14.5, last modified on August 06, 2024

Use the TestRunItems_LoadByCriteria operation to:

  • Get test run items that match a specific condition. For example, run by a specific user or have the specific status.

  • Get all test run items in QAComplete projects (if no condition is specified).

The operation can get test run items from one or several projects. To specify a project to get test run items from, use the ProjId value in the AuthenticationData object in the request body. To get test run items from several projects, use the ProjIds value in the AuthenticationData object to specify the list of project IDs.

LoadByCriteria returns results in pages (subsets of data) rather than all at once. Pagination is controlled by the PageSize and PageNumber parameters. For information about working with paginated results, see LoadByCriteria Operations.

You can use the Sorting parameter to sort the test run items before returning them from QAComplete.

To get just one test run item, use TestRunItems_Load.

Requirements

The authenticating user must belong to a user group that has the Read privilege for Test Library.

Parameters

The operation uses the following parameters:

AuthenticationData  :  AuthenticationData, required

An AuthenticationData object with the login information and the ID of the project (or the list of project IDs) that contains the related tests.

Condition  :  string (max 65536 chars)

An XML-formatted string that describes the test run items you want to get. For the syntax and examples, see Condition Syntax.

If you create SOAP requests manually, place the condition string inside CDATA.

To get all test run items, use an empty string or a null value.

Sorting  :  string (max 512 chars)

The order to sort the results before returning them from the web service. For example, by the item identifier or run date. The format is:

Property1 [ASC | DESC ][, Property2 [ASC | DESC ]] [, ...]]]

where property names are those of the TestRunItem object. If you omit ASC or DESC after a property name, test runs are sorted in ascending order.

Example values:

TestRunItemId
TestRunId, TestRunItemId
DateStarted DESC

To keep the default sort order, use an empty string or a null value.

PageSize  :  integer, required

Limits the number of test run items to return in one page. Possible values: 1..200.

The last page may have less items than PageSize. This means the end of the result set.

PageNumber  :  integer, required

A number starting from 1 that specifies the data page to return in the response. To get all pages, send several requests with increasing PageNumber values. For example, if PageSize is 100, PageNumber of 1 will return items 1..100, PageNumber of 2 – items 101..200 and so on.

If PageNumber exceeds the range, an empty array is returned. If PageNumber is the last page, this page may have less items than PageSize.

Result

An array of TestRunItem objects that contain information about test run items.

Example

Sample Code

This example loads all child items of the specified test run.

C#

string login = "[email protected]";
string password = "p@ssword";
int projID = 10372;

// Specifying the condition
string condition =
@"<Conditions xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
              xmlns:xsd='http://www.w3.org/2001/XMLSchema'
              Operation='opEQU'>
  <Items Type='tField'>
    <Value xsi:type='xsd:string'>TestRunId</Value>
  </Items>
  <Items Type='tString'>
    <Value xsi:type='xsd:string'>358</Value>
  </Items>
</Conditions>";
string sorting = "";
// Specify the number of test run items on a page
int pageSize = 200;

ServiceSoapClient service = new ServiceSoapClient();

// Preparing AuthenticationData
LoginInfo loginInfo = service.GetLoginInfo("", login, password);
AuthenticationData authData = new AuthenticationData();
authData.AppCode = loginInfo.AppCode;
authData.UserId = loginInfo.UserId;
authData.PassCode = password;
authData.DeptId = loginInfo.DeptId;
authData.ProjId = projID;

// Preparing an array of TestRunItem objects
TestRunItem[] testRunItems = new TestRunItem[0];
int pageNumber = 1;
do
{
  testRunItems = service.TestRunItems_LoadByCriteria(authData, condition, sorting, pageSize, pageNumber);
  foreach (TestRunItem testRunItem in testRunItems)
  {
    Console.WriteLine("Run of the test {0} at {1} is {2}", testRunItem.TestName, testRunItem.DateStarted, testRunItem.StatusCode);
    }
} while (testRunItems.Length == pageSize);

Java

String login = "[email protected]";
String password = "p@ssword";
int projID = 10372;

// Specifying the desired condition
String condition =
"<Conditions xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' \n" +
"            xmlns:xsd='http://www.w3.org/2001/XMLSchema'\n" +
"            Operation='opEQU'>\n" +
"  <Items Type='tField'>\n" +
"    <Value xsi:type='xsd:string'>TestRunId</Value>\n" +
"  </Items>\n" +
"  <Items Type='tString'>\n" +
"    <Value xsi:type='xsd:string'>358</Value>\n" +
"  </Items>\n" +
"</Conditions>\n";

// Specify the sorting
String sorting = "";
// Specify the number of test run items on a page
int pageSize = 200;

ServiceSoap service = new Service().getServiceSoap12();

// Preparing AuthenticationData
LoginInfo loginInfo = service.getLoginInfo("", login, password);
AuthenticationData authData = new AuthenticationData();
authData.setAppCode(loginInfo.getAppCode());
authData.setUserId(loginInfo.getUserId());
authData.setPassCode(password);
authData.setDeptId(loginInfo.getDeptId());
authData.setProjId(projID);

// Preparing an array of TestRunItem objects
List<TestRunItem> testRunItems;
int pageNumber = 1;

do
{
  testRunItems = service.testRunItemsLoadByCriteria(authData, condition, sorting, pageSize, pageNumber).getTestRunItem();
  for (TestRunItem testRunItem : testRunItems)
  {
    System.out.format("Run of the test %s at %s is %s%n", testRunItem.getTestName(), testRunItem.getDateStarted(), testRunItem.getStatusCode());
  }
  pageNumber++;
} while (testRunItems.size() == pageSize);

Sample Request XML

POST /psws/psws.asmx HTTP/1.1
Host: myteam.mysite.com
Content-Type: text/xml; charset=utf-8
Content-Length: 1040 {Insert an appropriate value here}
SOAPAction: "http://www.pragmaticsw.com/TestRunItems_LoadByCriteria"
 

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <TestRunItems_LoadByCriteria xmlns="http://www.pragmaticsw.com/">
      <AuthenticationData>
        <AppCode>agSP</AppCode>
        <DeptId>7154</DeptId>
        <ProjId>1032</ProjId>
        <UserId>25315</UserId>
        <PassCode>p@ssword</PassCode>
      </AuthenticationData>
      <Condition>
        <![CDATA[<Conditions xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
                             xmlns:xsd='http://www.w3.org/2001/XMLSchema'
                             Operation='opEQU'>
          <Items Type='tField'>
            <Value xsi:type='xsd:string'>TestRunId</Value>
          </Items>
          <Items Type='tString'>
            <Value xsi:type='xsd:string'>358</Value>
          </Items>
        </Conditions>]]>
      
</Condition>
      <Sorting>NbrFailed</Sorting>
      <PageSize>200</PageSize>
      <PageNumber>1</PageNumber>
    </TestRunItems_LoadByCriteria>
  </soap:Body>
</soap:Envelope>

SOAP 1.2

POST /psws/psws.asmx HTTP/1.1
Host: myteam.mysite.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 1048 {Insert an appropriate value here}
 

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <TestRunItems_LoadByCriteria xmlns="http://www.pragmaticsw.com/">
      <AuthenticationData>
        <AppCode>agSP</AppCode>
        <DeptId>7154</DeptId>
        <ProjId>1032</ProjId>
        <UserId>25315</UserId>
        <PassCode>p@ssword</PassCode>
      </AuthenticationData>
      <Condition>
        <![CDATA[<Conditions xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
                             xmlns:xsd='http://www.w3.org/2001/XMLSchema'
                             Operation='opEQU'>
          <Items Type='tField'>
            <Value xsi:type='xsd:string'>TestRunId</Value>
          </Items>
          <Items Type='tString'>
            <Value xsi:type='xsd:string'>358</Value>
          </Items>
        </Conditions>]]>
      
</Condition>
      <Sorting>NbrFailed</Sorting>
      <PageSize>200</PageSize>
      <PageNumber>1</PageNumber>
    </TestRunItems_LoadByCriteria>
  </soap12:Body>
</soap12:Envelope>

Sample Response XML

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: 1748 {The server returns an appropriate value here}
 

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <TestRunItems_LoadByCriteriaResponse xmlns="http://www.pragmaticsw.com/">
      <TestRunItems_LoadByCriteriaResult>
        <TestRunItem>
          <TestRunItemId>1354</TestRunItemId>
          <TestSetId>254</TestSetId>
          <ProjId>10372</ProjId>
          <TestRunId>358</TestRunId>
          <TestId>468</TestId>
          <Version>2</Version>
          <Seq>1</Seq>
          <DateStarted>2014-07-29T13:24:18:027</DateStarted>
          <DateFinished>2014-07-29T13:26:31:069</DateFinished>
          <RunTime>134</RunTime>
          <RunTimeFormated>00:02:14</RunTimeFormated>
          <IsStoppedOnFail>N</IsStoppedOnFail>
          <RunByUserName>Doe, John</RunByUserName>
          <ConfigurationName>Windows 7 (32-bit)</ConfigurationName>
          <TestSetName>Regression Tests - Release 3.1.0</TestSetName>
          <AvgRunTime>139</AvgRunTime>
          <AvgRunTimeFormated>00:02:19</AvgRunTimeFormated>
          <TestName>Test input data</TestName>
        </TestRunItem>
        <TestRunItem>
          <TestRunItemId>1357</TestRunItemId>
          <TestSetId>254</TestSetId>
          <ProjId>10372</ProjId>
          <TestRunId>358</TestRunId>
          <TestId>469</TestId>
          <Version>5</Version>
          <Seq>2</Seq>
          <DateStarted>2014-07-29T13:27:32:038</DateStarted>
          <DateFinished>2014-07-29T13:28:34:017</DateFinished>
          <RunTime>62</RunTime>
          <RunTimeFormated>00:01:02</RunTimeFormated>
          <IsStoppedOnFail>N</IsStoppedOnFail>
          <RunByUserName>Doe, John</RunByUserName>
          <ConfigurationName>Windows 7 (32-bit)</ConfigurationName>
          <TestSetName>Regression Tests - Release 3.1.0</TestSetName>
          <AvgRunTime>61</AvgRunTime>
          <AvgRunTimeFormated>00:01:01</AvgRunTimeFormated>
          <TestName>Test new controls</TestName>
        </TestRunItem>
      </TestRunItems_LoadByCriteriaResult>
    </TestRunItems_LoadByCriteriaResponse>
  </soap:Body>
</soap:Envelope>

SOAP 1.2

HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 1758 {The server returns an appropriate value here}
 

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <TestRunItems_LoadByCriteriaResponse xmlns="http://www.pragmaticsw.com/">
      <TestRunItems_LoadByCriteriaResult>
        <TestRunItem>
          <TestRunItemId>1354</TestRunItemId>
          <TestSetId>254</TestSetId>
          <ProjId>10372</ProjId>
          <TestRunId>358</TestRunId>
          <TestId>468</TestId>
          <Version>2</Version>
          <Seq>1</Seq>
          <DateStarted>2014-07-29T13:24:18:027</DateStarted>
          <DateFinished>2014-07-29T13:26:31:069</DateFinished>
          <RunTime>134</RunTime>
          <RunTimeFormated>00:02:14</RunTimeFormated>
          <IsStoppedOnFail>N</IsStoppedOnFail>
          <RunByUserName>Doe, John</RunByUserName>
          <ConfigurationName>Windows 7 (32-bit)</ConfigurationName>
          <TestSetName>Regression Tests - Release 3.1.0</TestSetName>
          <AvgRunTime>139</AvgRunTime>
          <AvgRunTimeFormated>00:02:19</AvgRunTimeFormated>
          <TestName>Test input data</TestName>
        </TestRunItem>
        <TestRunItem>
          <TestRunItemId>1357</TestRunItemId>
          <TestSetId>254</TestSetId>
          <ProjId>10372</ProjId>
          <TestRunId>358</TestRunId>
          <TestId>469</TestId>
          <Version>5</Version>
          <Seq>2</Seq>
          <DateStarted>2014-07-29T13:27:32:038</DateStarted>
          <DateFinished>2014-07-29T13:28:34:017</DateFinished>
          <RunTime>62</RunTime>
          <RunTimeFormated>00:01:02</RunTimeFormated>
          <IsStoppedOnFail>N</IsStoppedOnFail>
          <RunByUserName>Doe, John</RunByUserName>
          <ConfigurationName>Windows 7 (32-bit)</ConfigurationName>
          <TestSetName>Regression Tests - Release 3.1.0</TestSetName>
          <AvgRunTime>61</AvgRunTime>
          <AvgRunTimeFormated>00:01:01</AvgRunTimeFormated>
          <TestName>Test new controls</TestName>
        </TestRunItem>
      </TestRunItems_LoadByCriteriaResult>
    </TestRunItems_LoadByCriteriaResponse>
  </soap12:Body>
</soap12:Envelope>

See Also

TestRunItems_Load
TestRunItems_Update
Test Management Operations
Test Run Item Operations
SOAP API Reference

Highlight search results