TestCases_Add Operation

Applies to QAComplete 12.75 SaaS, last modified on April 01, 2021
This topic relates to the legacy Test Cases screen that provided basic test management functionality and was replaced with Test Management.
Starting from release 9.7.0, this functionality is obsolete and is supported only for backward compatibility.

Creates a new test case in QAComplete.

Use the ProjId value in the AuthenticationData parameter to specify the project to create the test case in it.

Requirements

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

Parameters

The operation uses the following parameters:

AuthenticationData  :  AuthenticationData, required

An AuthenticationData object containing the login information and the project ID to create the test case in.

TestCase  :  TestCase, required

A TestCase object that represents the test case you want to add to the project.

SendEmailAlert  :  string, required

Y means send an email alert to the subscribed users after adding the test case.

Any other value (for example, N or empty string) means do not send email alerts.

CreateDefectUponFailedTestCase  :  string

When you create failed test, you can specify Y to command QAComplete to create a linked defect based on the failed test case.

Any other value or null means do not create a defect.

NewNotes  :  string

A note to add to the test case.

Result

An integer ID of the created test case.

Remarks

The TestCase object you pass in must have all property values required by your QAComplete instance. You can see the required properties in two places:

  • Required fields for test cases:  > Setup > System Configuration > Screen Layouts > TestCases > Required Fields.

  • TestCase workflow transitions: Test Management > Test Cases > Actions > Manage Workflows > select status > Select fields for this Transition.

Do not specify the following properties, they are set automatically:

  • DateCreated and DateUpdated are set to the current date and time.

  • UpdateUserId and UserName are set to the authenticating user.

The TestCase 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

C#

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

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 the TestCase object
TestCase testCase = new TestCase();
testCase.Title = "Test internal text editor";
testCase.StatusCode = "Active";
testCase.Steps = @"<ol><li>Click Tools > Notepad.</li><li>Enter ""Test text"".</li><li>Close the Notepad dialog.</li></ol>";
testCase.ExpectedResults = "Offer to save the text must be shown";
testCase.AssigneeUserId = 27942;

// Adding the test case
int ID = service.TestCases_Add(authData, testCase, "N", "N", "");
Console.WriteLine("ID of the created test case: {0}", ID);

Java

String login = "john.doe@example.com";
String password = "p@ssword";
int projID = 10372;

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 the TestCase object
TestCase testCase = new TestCase();
testCase.setTitle("Test internal text editor");
testCase.setStatusCode("Active");
testCase.setSteps("<ol><li>Click Tools > Notepad.</li><li>Enter \"Test text\".</li><li>Close the Notepad dialog.</li></ol>");
testCase.setExpectedResults("Offer to save the text must be shown");
testCase.setAssigneeUserId(27942);

// Adding the test case
int ID = service.testCasesAdd(authData, testCase, "N", "N", "");
System.out.format("ID of the created test case: %d%n", ID);

Sample Request XML

POST /psws/psws.asmx HTTP/1.1
Host: myteam.mysite.com
Content-Type: text/xml; charset=utf-8
Content-Length: 945 {Insert an appropriate value here}
SOAPAction: "http://www.pragmaticsw.com/TestCases_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>
    <TestCases_Add xmlns="http://www.pragmaticsw.com/">
      <AuthenticationData>
        <AppCode>agSP</AppCode>
        <DeptId>7154</DeptId>
        <ProjId>1032</ProjId>
        <UserId>25315</UserId>
        <PassCode>p@ssword</PassCode>
      </AuthenticationData>
      <TestCase>
        <Title>Test internal text editor</Title>
        <StatusCode>Active</StatusCode>
        <Steps> <![CDATA[<ol><li>Click Tools > Notepad.</li><li>Enter "Test text".</li><li>Close the Notepad dialog.</li></ol>]]> </Steps>
        <ExpectedResults>An offer to save the text must be shown.An offer</ExpectedResults>
        <AssigneeUserId>27942</AssigneeUserId>
        <ActHrs>0.2</ActHrs>
        <AssignedToName>Doe, John</AssignedToName>
      </TestCase>
      <SendEmailAlert>N</SendEmailAlert>
      <NewNotes></NewNotes>
    </TestCases_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: 953 {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>
    <TestCases_Add xmlns="http://www.pragmaticsw.com/">
      <AuthenticationData>
        <AppCode>agSP</AppCode>
        <DeptId>7154</DeptId>
        <ProjId>1032</ProjId>
        <UserId>25315</UserId>
        <PassCode>p@ssword</PassCode>
      </AuthenticationData>
      <TestCase>
        <Title>Test internal text editor</Title>
        <StatusCode>Active</StatusCode>
        <Steps> <![CDATA[<ol><li>Click Tools > Notepad.</li><li>Enter "Test text".</li><li>Close the Notepad dialog.</li></ol>]]> </Steps>
        <ExpectedResults>An offer to save the text must be shown.An offer</ExpectedResults>
        <AssigneeUserId>27942</AssigneeUserId>
        <ActHrs>0.2</ActHrs>
        <AssignedToName>Doe, John</AssignedToName>
      </TestCase>
      <SendEmailAlert>N</SendEmailAlert>
      <NewNotes></NewNotes>
    </TestCases_Add>
  </soap12:Body>
</soap12:Envelope>

Sample Response XML

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

SOAP 1.2

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

See Also

TestCases_Delete
TestCases_Load
TestCases_LoadByCriteria
TestCases_LoadByUNC
TestCases_Update
Test Cases Operations (Releases 9.6.0 and Earlier)
SOAP API Reference

Highlight search results