Tests_LoadByCriteria Operation

Applies to QAComplete 12.84 SaaS, last modified on July 19, 2021
Since release 10.2, this functionality is obsolete and is supported for backward compatibility only. We recommend that you use QAComplete REST API to access and manage data in QAComplete.

Returns an array of Test objects that meet the specified condition. If no condition is specified, the method returns all tests from the specified projects.

The method returns results in pages (subsets of data) rather than all at once. The number of pages and the number of test steps each page contains is controlled by the PageSize and PageNumber parameters. For information about working with pages, see LoadByCriteria Operations.

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

Requirements

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

Parameters

The operation uses the following parameters:

AuthenticationData  :  object, required

An AuthenticationData object with the login information and the ID of the project (or the list of project IDs) whose tests you want to get.

Condition  :  string, required

A condition (in XML format) the tests should meet. Wrap the condition into the CDATA tag or encode XML entities.

If you do not specify a condition, the method will return all tests in the Test Library.

Sorting  :  string, required

Specifies a property by which the method will sort the tests. If you do not specify any property for sorting, the method will sort the tests by ID.

PageSize  :  integer, required

Specifies how many tests a single page contains (from 1 to 200).

PageNumber  :  integer, required

Specifies the number of the page from which you want to get tests.

Result

An array of the Test objects that meet the criteria.

Example

Sample Code

C#

string login = "john.doe@example.com";
string password = "p@ssword";

ServiceSoapClient service = new ServiceSoapClient();

// Prepare 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 = loginInfo.ProjId;

// Specify 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'>LastRunStatus</Value>
          </Items>
          <Items Type='tString'>
            <Value xsi:type='xsd:string'>Passed</Value>
          </Items>
        </Conditions>";

// Specify the sorting
string sorting = "TestId";
// Specify the number of tests on a page
int pageSize = 200;
// Specify the number of a page
int pageNumber = 1;

// Get the array of tests
Test[] tests = new Test[0];
do
{
  tests = service.Tests_LoadByCriteria(authData, condition, sorting, pageSize, pageNumber);
    foreach (Test test in tests)
    {
      // Printing ID and title of each test
      Console.WriteLine("{0}: {1} ()", test.TestId, test.Title);
    }
  pageNumber++;
}
while (tests.Length == pageSize);

Java

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

// Prepare AuthenticationData
String login = "john.doe@example.com";
String password = "p@ssword";

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(loginInfo.getProjId());

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

// Specify the sorting
String sorting = "TestId";
// Specify the number of tests on a page
int pageSize = 200;
// Specify the number of a page
int pageNumber = 1;
// Get the array of tests
List<Test> tests;
do
{
  tests = service.testsLoadByCriteria(authData, condition, sorting, pageSize, pageNumber).getTest();
  for (Test test : tests)
  {
    // Printing the ID and title of each test
    System.out.format("%d: %s%n", test.getTestId(), test.getTitle());
  }
  pageNumber++;
}
while (tests.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: 902 {Insert an appropriate value here}
SOAPAction: "http://www.pragmaticsw.com/Tests_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>
    <Tests_LoadByCriteria xmlns="http://www.pragmaticsw.com/">
      <AuthenticationData>
      </AuthenticationData>
      <Condition> &lt;Conditions xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'&#xD;
          xmlns:xsd='http://www.w3.org/2001/XMLSchema' Operation='opEQU'&gt;&#xD;
          &lt;Items Type='tField'&gt; &#xD;
            &lt;Value xsi:type='xsd:string'&gt;LastRunStatus&lt;/Value&gt; &#xD;
          &lt;/Items&gt; &#xD;
          &lt;Items Type='tString'&gt; &#xD;
            &lt;Value xsi:type='xsd:string'&gt;Passed&lt;/Value&gt; &#xD;
          &lt;/Items&gt; &#xD;
&lt;/Conditions&gt;
</Condition>
      <Sorting>TestId</Sorting>
      <PageSize>200</PageSize>
      <PageNumber>1</PageNumber>
    </Tests_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: 910 {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>
    <Tests_LoadByCriteria xmlns="http://www.pragmaticsw.com/">
      <AuthenticationData>
      </AuthenticationData>
      <Condition> &lt;Conditions xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'&#xD;
          xmlns:xsd='http://www.w3.org/2001/XMLSchema' Operation='opEQU'&gt;&#xD;
          &lt;Items Type='tField'&gt; &#xD;
            &lt;Value xsi:type='xsd:string'&gt;LastRunStatus&lt;/Value&gt; &#xD;
          &lt;/Items&gt; &#xD;
          &lt;Items Type='tString'&gt; &#xD;
            &lt;Value xsi:type='xsd:string'&gt;Passed&lt;/Value&gt; &#xD;
          &lt;/Items&gt; &#xD;
&lt;/Conditions&gt;
</Condition>
      <Sorting>TestId</Sorting>
      <PageSize>200</PageSize>
      <PageNumber>1</PageNumber>
    </Tests_LoadByCriteria>
  </soap12:Body>
</soap12:Envelope>

Sample Response XML

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: 3408 {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>
    <Tests_LoadByCriteriaResponse xmlns="http://www.pragmaticsw.com/">
      <Tests_LoadByCriteriaResult>
        <Test>
          <FolderName>Regression Tests</FolderName>
          <AssignedToName>Doe, John</AssignedToName>
          <UserName>Doe, John</UserName>
          <OwnerName>Doe, John</OwnerName>
          <LastRunByName>Doe, John</LastRunByName>
          <TestId>2</TestId>
          <Version>3</Version>
          <ProjId>11873</ProjId>
          <FolderId>12</FolderId>
          <Title>Test input data</Title>
          <IsActive>Y</IsActive>
          <StatusCode>Approved</StatusCode>
          <ExecutionType>Manual</ExecutionType>
          <TestType>Regression</TestType>
          <Priority>1-High</Priority>
          <Description>Test input data</Description>
          <DateCreated>2014-07-17T08:30:28</DateCreated>
          <DateUpdated>2014-07-20T10:53:07</DateUpdated>
          <CreateUserId>24661</CreateUserId>
          <UpdateUserId>24661</UpdateUserId>
          <AssigneeUserId>24661</AssigneeUserId>
          <OwnerUserId>24661</OwnerUserId>
          <OriginalId>0</OriginalId>
          <ImportId>0</ImportId>
          <ScriptSourceId>0</ScriptSourceId>
          <NbrFailStatus>2</NbrFailStatus>
          <NbrPassStatus>4</NbrPassStatus>
          <AvgRunTime>375</AvgRunTime>
          <AvgRunTimeFormated>00:06:15</AvgRunTimeFormated>
          <NbrTimesRun>6</NbrTimesRun>
          <LastRunByUserId>24661</LastRunByUserId>
          <LastRunTestSet>2</LastRunTestSet>
          <LastRunTestSetTitle>Regression Tests</LastRunTestSetTitle>
          <LastRunDate>2014-07-20T10:53:07</LastRunDate>
          <LastRunStatus>Passed</LastRunStatus>
          <NbrSteps>10</NbrSteps>
          <NbrEscalations>0</NbrEscalations>
          <DateLastEscalated>0001-01-01T00:00:00</DateLastEscalated>
          <LastEscalationRuleId>0</LastEscalationRuleId>
          <NbrFilesNotSecured>0</NbrFilesNotSecured>
          <NbrFiles>0</NbrFiles>
          <NbrNotes>0</NbrNotes>
          <NbrEvents>0</NbrEvents>
          <ScriptName></ScriptName>
        </Test>
        <Test>
          <FolderName>Automation Tests</FolderName>
          <AssignedToName>Doe, John</AssignedToName>
          <UserName>Doe, John</UserName>
          <OwnerName>Doe, John</OwnerName>
          <LastRunByName>Doe, Jane</LastRunByName>
          <TestId>3</TestId>
          <Version>1</Version>
          <ProjId>11873</ProjId>
          <FolderId>21</FolderId>
          <Title>Test new controls</Title>
          <IsActive>Y</IsActive>
          <StatusCode>Awaiting Approval</StatusCode>
          <ExecutionType>Automatic</ExecutionType>
          <TestType>Smoke Test</TestType>
          <Priority>2-Medium</Priority>
          <Description>Test input controls</Description>
          <DateCreated>2014-07-18T10:13:16</DateCreated>
          <DateUpdated>2014-07-22T11:14:18</DateUpdated>
          <CreateUserId>24661</CreateUserId>
          <UpdateUserId>24667</UpdateUserId>
          <AssigneeUserId>24667</AssigneeUserId>
          <OwnerUserId>24661</OwnerUserId>
          <OriginalId>0</OriginalId>
          <ImportId>0</ImportId>
          <ScriptSourceId>0</ScriptSourceId>
          <NbrFailStatus>0</NbrFailStatus>
          <NbrPassStatus>12</NbrPassStatus>
          <AvgRunTime>342</AvgRunTime>
          <AvgRunTimeFormated>00:05:42</AvgRunTimeFormated>
          <NbrTimesRun>12</NbrTimesRun>
          <LastRunByUserId>24667</LastRunByUserId>
          <LastRunTestSet>3</LastRunTestSet>
          <LastRunTestSetTitle>Smoke Tests</LastRunTestSetTitle>
          <LastRunDate>2014-07-22T11:14:18</LastRunDate>
          <LastRunStatus>Passed</LastRunStatus>
          <NbrSteps>1</NbrSteps>
          <NbrEscalations>0</NbrEscalations>
          <DateLastEscalated>0001-01-01T00:00:00</DateLastEscalated>
          <LastEscalationRuleId>0</LastEscalationRuleId>
          <NbrFilesNotSecured>0</NbrFilesNotSecured>
          <NbrFiles>0</NbrFiles>
          <NbrNotes>0</NbrNotes>
          <NbrEvents>0</NbrEvents>
          <ScriptName></ScriptName>
        </Test>
      </Tests_LoadByCriteriaResult>
    </Tests_LoadByCriteriaResponse>
  </soap:Body>
</soap:Envelope>

SOAP 1.2

HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 3418 {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>
    <Tests_LoadByCriteriaResponse xmlns="http://www.pragmaticsw.com/">
      <Tests_LoadByCriteriaResult>
        <Test>
          <FolderName>Regression Tests</FolderName>
          <AssignedToName>Doe, John</AssignedToName>
          <UserName>Doe, John</UserName>
          <OwnerName>Doe, John</OwnerName>
          <LastRunByName>Doe, John</LastRunByName>
          <TestId>2</TestId>
          <Version>3</Version>
          <ProjId>11873</ProjId>
          <FolderId>12</FolderId>
          <Title>Test input data</Title>
          <IsActive>Y</IsActive>
          <StatusCode>Approved</StatusCode>
          <ExecutionType>Manual</ExecutionType>
          <TestType>Regression</TestType>
          <Priority>1-High</Priority>
          <Description>Test input data</Description>
          <DateCreated>2014-07-17T08:30:28</DateCreated>
          <DateUpdated>2014-07-20T10:53:07</DateUpdated>
          <CreateUserId>24661</CreateUserId>
          <UpdateUserId>24661</UpdateUserId>
          <AssigneeUserId>24661</AssigneeUserId>
          <OwnerUserId>24661</OwnerUserId>
          <OriginalId>0</OriginalId>
          <ImportId>0</ImportId>
          <ScriptSourceId>0</ScriptSourceId>
          <NbrFailStatus>2</NbrFailStatus>
          <NbrPassStatus>4</NbrPassStatus>
          <AvgRunTime>375</AvgRunTime>
          <AvgRunTimeFormated>00:06:15</AvgRunTimeFormated>
          <NbrTimesRun>6</NbrTimesRun>
          <LastRunByUserId>24661</LastRunByUserId>
          <LastRunTestSet>2</LastRunTestSet>
          <LastRunTestSetTitle>Regression Tests</LastRunTestSetTitle>
          <LastRunDate>2014-07-20T10:53:07</LastRunDate>
          <LastRunStatus>Passed</LastRunStatus>
          <NbrSteps>10</NbrSteps>
          <NbrEscalations>0</NbrEscalations>
          <DateLastEscalated>0001-01-01T00:00:00</DateLastEscalated>
          <LastEscalationRuleId>0</LastEscalationRuleId>
          <NbrFilesNotSecured>0</NbrFilesNotSecured>
          <NbrFiles>0</NbrFiles>
          <NbrNotes>0</NbrNotes>
          <NbrEvents>0</NbrEvents>
          <ScriptName></ScriptName>
        </Test>
        <Test>
          <FolderName>Automation Tests</FolderName>
          <AssignedToName>Doe, John</AssignedToName>
          <UserName>Doe, John</UserName>
          <OwnerName>Doe, John</OwnerName>
          <LastRunByName>Doe, Jane</LastRunByName>
          <TestId>3</TestId>
          <Version>1</Version>
          <ProjId>11873</ProjId>
          <FolderId>21</FolderId>
          <Title>Test new controls</Title>
          <IsActive>Y</IsActive>
          <StatusCode>Awaiting Approval</StatusCode>
          <ExecutionType>Automatic</ExecutionType>
          <TestType>Smoke Test</TestType>
          <Priority>2-Medium</Priority>
          <Description>Test input controls</Description>
          <DateCreated>2014-07-18T10:13:16</DateCreated>
          <DateUpdated>2014-07-22T11:14:18</DateUpdated>
          <CreateUserId>24661</CreateUserId>
          <UpdateUserId>24667</UpdateUserId>
          <AssigneeUserId>24667</AssigneeUserId>
          <OwnerUserId>24661</OwnerUserId>
          <OriginalId>0</OriginalId>
          <ImportId>0</ImportId>
          <ScriptSourceId>0</ScriptSourceId>
          <NbrFailStatus>0</NbrFailStatus>
          <NbrPassStatus>12</NbrPassStatus>
          <AvgRunTime>342</AvgRunTime>
          <AvgRunTimeFormated>00:05:42</AvgRunTimeFormated>
          <NbrTimesRun>12</NbrTimesRun>
          <LastRunByUserId>24667</LastRunByUserId>
          <LastRunTestSet>3</LastRunTestSet>
          <LastRunTestSetTitle>Smoke Tests</LastRunTestSetTitle>
          <LastRunDate>2014-07-22T11:14:18</LastRunDate>
          <LastRunStatus>Passed</LastRunStatus>
          <NbrSteps>1</NbrSteps>
          <NbrEscalations>0</NbrEscalations>
          <DateLastEscalated>0001-01-01T00:00:00</DateLastEscalated>
          <LastEscalationRuleId>0</LastEscalationRuleId>
          <NbrFilesNotSecured>0</NbrFilesNotSecured>
          <NbrFiles>0</NbrFiles>
          <NbrNotes>0</NbrNotes>
          <NbrEvents>0</NbrEvents>
          <ScriptName></ScriptName>
        </Test>
      </Tests_LoadByCriteriaResult>
    </Tests_LoadByCriteriaResponse>
  </soap12:Body>
</soap12:Envelope>

See Also

Tests_Add
Tests_Delete
Tests_Load
Tests_Update
Test Management Operations
Test Operations
SOAP API Reference

Highlight search results