TestSetItems_Add Operation

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

Adds a new item to the test set in your project and returns the ID of the added item. The TestSetItem.TestSetId property of the appropriate TestSetItem object defines the ID of the test set to which you add the item. The TestSetItem.TestId property defines the ID of the test the item is to run.

Requirements

The user must belong to a security group that has the following privileges:

  • The Read privilege for Test Library.

  • The Update privilege for Test Management > Test Sets.

Parameters

The operation uses the following parameters:

AuthenticationData  :  AuthenticationData, required

An AuthenticationData object containing the login information and the ID of the project to whose test set you want to add a new item.

TestSetItem  :  TestSetItem, required

The TestSetItem object to add to the test set.

SendEmailAlert  :  string, required

Y if you want to send an email alert; N otherwise.

Result

The ID of the added test set item.

Remarks

The TestSetItem object you pass to the method must have the TestSetId and TestId properties specified.

The TestSetItem object has matching Id and Name properties, for example, FolderId and FolderName. To set them, specify the value only for the Id property. The corresponding Name property will be set automatically.

Example

Sample Code

This example creates a test set with two tests.

C#

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

// Specifying properties of the test set
string title = "Regression Tests - Release 3.1.0";
string status = "New";

// Specify the IDs of the tests associated with the items
int[] testIDs = { 1, 2 };

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 = projID;

// Prepare the TestSet object
TestSet set = new TestSet();
set.Title = title;
set.StatusCode = status;

// Add the test set
int testSetId = service.TestSets_Add(authData, set, "Y", "This test set was added from code.");
Console.WriteLine("The ID of the created test set: {0}", testSetId);

for (int i=0; i<2; i++)
{
  // Prepare the TestSetItem object
  TestSetItem item = new TestSetItem();
  item.TestSetId = testSetId;
  item.TestId = testIDs[i];

  // Add the test set item
  int testSetItemId = service.TestSetItems_Add(authData, item, "Y");
  Console.WriteLine("The test set item {0} was added to the test set {1}", testSetItemId, testSetId);
}

Java

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

// Specify properties of the test set
String title = "Regression Tests - Release 3.1.0";
String status = "New";

// Specify the IDs of the tests associated with the items
int[] testIDs = {1, 2};

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

// Prepare 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);

// Prepare the TestSet object
TestSet set = new TestSet();
set.setTitle(title);
set.setStatusCode(status);

// Add the test set
int testSetId = service.testSetsAdd(authData, set, "Y", "This test set was added from code.");
System.out.format("The ID of the created test set: %d%n", testSetId);

for (int i=0; i<2; i++)
{
  // Prepare the TestSetItem object
  TestSetItem item = new TestSetItem();
  item.setTestSetId(testSetId);
  item.setTestId(testIDs[i]);

  // Add the test set item
  int testSetItemId = service.testSetItemsAdd(authData, item, "Y");
  System.out.format("The test set item %d was added to the test set %d%n", testSetItemId, testSetId);
}

Sample Request XML

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

<?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>
    <TestSetItems_Add xmlns="http://www.pragmaticsw.com/">
      <AuthenticationData>
        <AppCode>agSP</AppCode>
        <DeptId>8162</DeptId>
        <ProjId>11873</ProjId>
        <UserId>24661</UserId>
        <PassCode>p@ssword</PassCode>
      </AuthenticationData>
      <TestSetItem>
        <TestSetItemId>0</TestSetItemId>
        <TestSetId>1</TestSetId>
        <TestId>1</TestId>
        <Seq>0</Seq>
        <DateCreated>0001-01-01T00:00:00</DateCreated>
        <DateUpdated>0001-01-01T00:00:00</DateUpdated>
        <CreateUserId>0</CreateUserId>
        <UpdateUserId>0</UpdateUserId>
        <Version>0</Version>
        <ProjId>0</ProjId>
        <FolderId>0</FolderId>
        <TestDateCreated>0001-01-01T00:00:00</TestDateCreated>
        <TestDateUpdated>0001-01-01T00:00:00</TestDateUpdated>
        <TestCreateUserId>0</TestCreateUserId>
        <TestUpdateUserId>0</TestUpdateUserId>
        <AssigneeUserId>0</AssigneeUserId>
        <OwnerUserId>0</OwnerUserId>
        <OriginalId>0</OriginalId>
        <ImportId>0</ImportId>
        <ScriptSourceId>0</ScriptSourceId>
        <NbrFailStatus>0</NbrFailStatus>
        <NbrPassStatus>0</NbrPassStatus>
        <AvgRunTime>0</AvgRunTime>
        <NbrTimesRun>0</NbrTimesRun>
        <LastRunByUserId>0</LastRunByUserId>
        <LastRunTestSet>0</LastRunTestSet>
        <LastRunDate>0001-01-01T00:00:00</LastRunDate>
        <NbrSteps>0</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>
      </TestSetItem>
      <SendEmailAlert>Y</SendEmailAlert>
    </TestSetItems_Add>
  </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: 1676 {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>
    <TestSetItems_Add xmlns="http://www.pragmaticsw.com/">
      <AuthenticationData>
        <AppCode>agSP</AppCode>
        <DeptId>8162</DeptId>
        <ProjId>11873</ProjId>
        <UserId>24661</UserId>
        <PassCode>p@ssword</PassCode>
      </AuthenticationData>
      <TestSetItem>
        <TestSetItemId>0</TestSetItemId>
        <TestSetId>1</TestSetId>
        <TestId>1</TestId>
        <Seq>0</Seq>
        <DateCreated>0001-01-01T00:00:00</DateCreated>
        <DateUpdated>0001-01-01T00:00:00</DateUpdated>
        <CreateUserId>0</CreateUserId>
        <UpdateUserId>0</UpdateUserId>
        <Version>0</Version>
        <ProjId>0</ProjId>
        <FolderId>0</FolderId>
        <TestDateCreated>0001-01-01T00:00:00</TestDateCreated>
        <TestDateUpdated>0001-01-01T00:00:00</TestDateUpdated>
        <TestCreateUserId>0</TestCreateUserId>
        <TestUpdateUserId>0</TestUpdateUserId>
        <AssigneeUserId>0</AssigneeUserId>
        <OwnerUserId>0</OwnerUserId>
        <OriginalId>0</OriginalId>
        <ImportId>0</ImportId>
        <ScriptSourceId>0</ScriptSourceId>
        <NbrFailStatus>0</NbrFailStatus>
        <NbrPassStatus>0</NbrPassStatus>
        <AvgRunTime>0</AvgRunTime>
        <NbrTimesRun>0</NbrTimesRun>
        <LastRunByUserId>0</LastRunByUserId>
        <LastRunTestSet>0</LastRunTestSet>
        <LastRunDate>0001-01-01T00:00:00</LastRunDate>
        <NbrSteps>0</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>
      </TestSetItem>
      <SendEmailAlert>Y</SendEmailAlert>
    </TestSetItems_Add>
  </soap12:Body>
</soap12:Envelope>

Sample Response XML

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: 385 {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>
    <TestSetItems_AddResponse xmlns="http://www.pragmaticsw.com/">
      <TestSetItems_AddResult>1</TestSetItems_AddResult>
    </TestSetItems_AddResponse>
  </soap:Body>
</soap:Envelope>

SOAP 1.2

HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 395 {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>
    <TestSetItems_AddResponse xmlns="http://www.pragmaticsw.com/">
      <TestSetItems_AddResult>1</TestSetItems_AddResult>
    </TestSetItems_AddResponse>
  </soap12:Body>
</soap12:Envelope>

See Also

TestSetItems_Delete
TestSetItems_Load
TestSetItems_LoadByCriteria
TestSetItems_Update
Test Management Operations
Test Set Items Operations
SOAP API Reference

Highlight search results