Tests_Add Operation

Applies to QAComplete 14.5, last modified on August 06, 2024
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.

Adds a new test to the Test Library in QAComplete and returns the ID of the added test.

After you create a test, you can add steps to it. To do this, call TestSteps_Add and set the TestId property of the steps to the ID of the created test.

Requirements

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

Parameters

The operation uses the following parameters:

AuthenticationData  :  AuthenticationData, required

An AuthenticationData object containing the login information and the ID of the project to which you want to add a test.

Test  :  Test, required

The Test object to add to the Test Library.

SendEmailAlert  :  string, required

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

NewNotes  :  string, required

A note to attach to the test.

Result

The ID of the added test.

Remarks

The Test object you pass to the method must have all properties required by your instance of QAComplete specified. To learn what properties are required:

  • In QAComplete, open  > Setup > System Configuration > Screen Layouts > Test Library > Required Fields. View the required test properties on the Required Fields list.

  • In QAComplete, open Test Management > Test Library >  Tools >  Manage Workflows. Select the desired test status on the Status list and click Select fields for this Transition to view the list of required test properties.

The Test 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 with two steps.

C#

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

// Specifying test properties
string testTitle = "Test input data";
string testStatus = "New";

// Specifying steps properties
string[] Steps = {"Select Tools from the application's main menu.",
                  "Switch to the Java tabbed page."};
string[] expectedResults = {"The Tools dialog opens.",
                            "The Java tabbed page shows the path to the Java Virtual machine module."};
int[] Seqs = { 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;

// Preparing a new test
Test test = new Test();
test.Title = testTitle;
test.StatusCode = testStatus;

// Add the test
int testId = service.Tests_Add(authData, test, "Y", "This test was added from code.");
Console.WriteLine("Id of the created test: {0}", testId);

for (int i = 0; i < 2; i++)
{
// Preparing the step objects
  TestStep step = new TestStep();
  step.TestId = testId;
  step.Step = Steps[i];
  step.ExpectedResult = expectedResults[i];
  step.Seq = Seqs[i];

  // Adding the step
  int stepId = service.TestSteps_Add(authData, step, "Y");
  Console.WriteLine("Step {0} was added to the test {1}", stepId, testId);
}

Java

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

// Specifying test properties
String testTitle = "Test input data";
String testStatus = "New";

// Specifying steps properties
String[] Steps = {"Select Tools from the application's main menu.",
        "Switch to the Java tabbed page."};
String[] expectedResults = {"The Tools dialog opens.",
        "The Java tabbed page shows the path to the Java Virtual machine module."};
int[] Seqs = { 1, 2 };

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 a new test
Test test = new Test();
test.setTitle(testTitle);
test.setStatusCode(testStatus);

// Adding the test
int testId = service.testsAdd(authData, test, "Y", "This test was added from code.");
System.out.format("Id of the created test: %d%n", testId);

for (int i = 0; i < 2; i++)
{
  // Preparing the step objects
  TestStep step = new TestStep();
  step.setTestId(testId);
  step.setStep(Steps[i]);
  step.setExpectedResult(expectedResults[i]);
  step.setSeq(Seqs[i]);

  // Adding the step
  int stepId = service.testStepsAdd(authData, step, "Y");
  System.out.format("Step %d was added to the test %d%n", stepId, testId);
}

Sample Request XML

POST /psws/psws.asmx HTTP/1.1
Host: myteam.mysite.com
Content-Type: text/xml; charset=utf-8
Content-Length: 1522 {Insert an appropriate value here}
SOAPAction: "http://www.pragmaticsw.com/Tests_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>
    <Tests_Add xmlns="http://www.pragmaticsw.com/">
      <AuthenticationData>
        <AppCode>agSP</AppCode>
        <DeptId>8162</DeptId>
        <ProjId>11873</ProjId>
        <UserId>24661</UserId>
        <PassCode>p@ssword</PassCode>
      </AuthenticationData>
      <Test>
        <TestId>0</TestId>
        <Version>0</Version>
        <ProjId>0</ProjId>
        <FolderId>0</FolderId>
        <Title>Test input data</Title>
        <StatusCode>New</StatusCode>
        <DateCreated>0001-01-01T00:00:00</DateCreated>
        <DateUpdated>0001-01-01T00:00:00</DateUpdated>
        <CreateUserId>0</CreateUserId>
        <UpdateUserId>0</UpdateUserId>
        <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>
        <ScriptName></ScriptName>
      </Test>
      <SendEmailAlert>Y</SendEmailAlert>
      <NewNotes>This test was added from code.</NewNotes>
    </Tests_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: 1530 {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_Add xmlns="http://www.pragmaticsw.com/">
      <AuthenticationData>
        <AppCode>agSP</AppCode>
        <DeptId>8162</DeptId>
        <ProjId>11873</ProjId>
        <UserId>24661</UserId>
        <PassCode>p@ssword</PassCode>
      </AuthenticationData>
      <Test>
        <TestId>0</TestId>
        <Version>0</Version>
        <ProjId>0</ProjId>
        <FolderId>0</FolderId>
        <Title>Test input data</Title>
        <StatusCode>New</StatusCode>
        <DateCreated>0001-01-01T00:00:00</DateCreated>
        <DateUpdated>0001-01-01T00:00:00</DateUpdated>
        <CreateUserId>0</CreateUserId>
        <UpdateUserId>0</UpdateUserId>
        <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>
        <ScriptName></ScriptName>
      </Test>
      <SendEmailAlert>Y</SendEmailAlert>
      <NewNotes>This test was added from code.</NewNotes>
    </Tests_Add>
  </soap12:Body>
</soap12:Envelope>

Sample Response XML

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: 357 {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_AddResponse xmlns="http://www.pragmaticsw.com/">
      <Tests_AddResult>2</Tests_AddResult>
    </Tests_AddResponse>
  </soap:Body>
</soap:Envelope>

SOAP 1.2

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

See Also

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

Highlight search results