PUT/projects/{ProjectId}/tests/{Id}

Applies to QAComplete 12.70 SaaS, last modified on January 11, 2021

Updates the specified test in QAComplete.

Use the operation to replace the contents of an existing test in QAComplete with new contents.

To update individual fields of an existing test, use the …/tests/{Id} (PATCH) operation.

To add a new test, use the …/tests (POST) operation.

Authentication

Basic authentication using a user’s login and password. See Authentication for details.

Security Rights

The authenticating user must belong to a security group that has the Update privilege for Tests.

Request Format

To update the test, send a PUT request to the following URL:

http://{server}/rest-api/service/api/v1/projects/{ProjectId}/tests/{Id}
URL parameters

ProjectId  :  integer, required

The ID of the project, to which the test belongs.

Id  :  integer, required

The ID of the test you want to update.

Body parameters

In the request body, pass the RequestTestPut JSON object that describes the test’s new contents:

{
  "Title": "string",
  "Status": "string",
  "Active": "boolean",
  "AssigneeUserId": "int",
  "CustomFields": [
    {
      "Id": "string",
      "Name": "string",
      "Value": "string"
    }
  ],
  "Description": "string",
  "ExecutionType": "string",
  "FolderId": "int",
  "OwnerUserId": "int",
  "Priority": "string",
  "TestSteps": [
    {
      "Id": "int",
      "Seq": "int",
      "IsStoppedOnFail": "boolean",
      "Step": "string",
      "ExpectedResult": "string",
      "ScriptSourceId": "int"
    },
  ],
  "TestType": "string"
}

The property values you do not specify are set to their default values.

Some string property values (for example, Status) are based on the choice lists defined in your QAComplete project. You can find these values in the Test Management > Test Library >  Tools >  Manage Choice Lists panel in QAComplete.

Title  :  string, required

The title of the test.

Status  :  string, required

The status of the test. Possible values are based on the choice list.

Active  :  boolean

Specifies whether the test is enabled (active).

AssigneeUserId  :  integer

The ID of the user to whom the test is assigned. 0 if the test is not assigned to anyone.

CustomFields  :  array of objects

An array of CustomFields objects that describe custom fields and their values:


{
  "Id": "string",
  "Name": "string",
  "Value": "string"
}

Id  :  string, required

The unique identifier of the custom field. Must be in the CustomN format, where N is the custom field’s number (index).

Name  :  string

The field name.

Value  :  string

The field value.

Description  :  string

The test description. Can include an HTML markup. If no description is specified, empty string.

ExecutionType  :  string

Specifies how the test will run. Possible values are based on the choice list. If no execution type is assigned, empty string.

FolderId  :  integer

The ID of the folder to which the test belongs.

OwnerUserId  :  integer

The ID of the user who owns the test.

Priority  :  string

Specifies the test priority. Possible values are based on the choice list. If no priority is assigned, empty string.

TestSteps  :  array of objects

An array of RequestTestStep objects that describe the test steps.

{
  "Id": "int",
  "Seq": "int",
  "IsStoppedOnFail": "boolean",
  "Step": "string",
  "ExpectedResult": "string",
  "ScriptSourceId": "int"
}

Id  :  integer, required

The unique identifier of the step among other test steps in the Test Library.

ExpectedResult  :  string

Describes the expected outcome of the actions a tester performs during the step. Can contain an HTML markup.

IsStoppedOnFail  :  boolean

Specifies whether the test will stop if the step fails. Default value: False.

Seq  :  integer, required

The ordinal number of the step in the test. Default value: 0.

ScriptSourceId  :  integer

Reserved.

Step  :  string, required

Describes instructions for a tester to follow during the step. Can contain an HTML markup.

TestType  :  string

Type of the test. Possible values are based on the choice list. If no type is assigned, empty string.

A sample request:

PUT http://yourserver.com/rest-api/service/api/v1/projects/11873/tests/8 HTTP/1.1
Host: yourserver.com
Connection: keep-alive
Content-Type: application/json
Accept: application/json
Authorization: Basic am9obkBleGFtcGxlLmNvbTpwQHNzd29yZA==
Content-Length: 461

{
  "Title": "Test input data",
  "Status": "Approved",
  "AssigneeUserId": 25264,
  "Priority": "1-High",
  "TestSteps": [
    {
      "Id": 1,
      "Seq": 1,
      "Step": "Select Tools from the application's main menu.",
      "ExpectedResult": "The Tools dialog opens."
    },
    {
      "Id": 2,
      "Seq": 2,
      "Step": "Switch to the Java tab.",
      "ExpectedResult": "The Java tab shows the path to the Java Virtual machine module."
    }
  ]
}

A sample request made by using cURL:

curl -u john@example.com:p@ssword -d @test.txt -H "Content-Type: application/json" -H "Accept: application/json" http://yourserver.com/service/api/v1/projects/11873/tests/8

Response Format

On success, the operation responds with HTTP status code 200 and returns a JSON object with the updated test information.

A sample response:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Content-Length: 1700


{
  "id": 10,
  "title": "Test input data",
  "status": "Approved",
  "project_id": 11873,
  "__permissions": {
    "acl": 7
  },
  "active": false,
  "assigned_to_name": "Smith, John",
  "assignee_user_id": 25264,
  "avg_run_time": 0,
  "create_user_id": 25264,
  "custom_fields": [],
  "date_created": "2015-08-30T11:39:02.3130000",
  "date_last_escalated": "0001-01-01T00:00:00.0000000",
  "date_updated": "2015-09-09T09:24:20.7900000",
  "execution_type": "",
  "folder_id": 0,
  "import_id": 0,
  "last_escalation_rule_id": 0,
  "last_run_by_name": "",
  "last_run_by_user_id": 0,
  "last_run_date": "0001-01-01T00:00:00.0000000",
  "last_run_test_set": 0,
  "nbr_escalations": 0,
  "nbr_events": 0,
  "nbr_fail_status": 0,
  "nbr_files": 0,
  "nbr_files_not_secured": 0,
  "nbr_notes": 0,
  "nbr_pass_status": 0,
  "nbr_steps": 0,
  "nbr_times_run": 0,
  "original_id": 0,
  "owner_user_id": 0,
  "script_name": "",
  "script_source_id": 0,
  "test_steps": [
    {
      "id": 1,
      "permissions": {
        "acl": 7
      },
      "create_user_id": 25264,
      "date_created": "2015-08-30T11:39:02.3130000",
      "date_updated": "2015-09-09T09:24:20.7900000",
      "expected_result": "The Tools dialog opens",
      "is_stopped_on_fail": false,
      "nbr_files": 0,
      "script_name": "",
      "script_source_id": 0,
      "seq": 1,
      "step": "Select Tools from the application's main menu.",
      "title": "Test input data",
      "update_user_id": 25264
    },
    {
      "id": 2,
      "permissions": {
        "acl": 7
      },
      "create_user_id": 25264,
      "date_created": "2015-08-30T11:39:02.3130000",
      "date_updated": "2015-09-09T09:24:20.7900000",
      "expected_result": "The Java tab shows the path to the Java Virtual machine module.",
      "is_stopped_on_fail": false,
      "nbr_files": 0,
      "script_name": "",
      "script_source_id": 0,
      "seq": 2,
      "step": "Switch to the Java tab.", 
      "title": "Test input data",
      "update_user_id": 25264
    }
  ],
  "update_user_id": 25264,
  "user_name": "Smith, John",
  "version": 1
}

Error responses

If the operation fails, it returns the appropriate status code and (optionally) the error description in the response body.

If the project with the specified ProjectId does not exist or the authenticating user does not have rights to access the project, the operation returns the Access is denied error.

If the test with the specified Id does not exist, the operation returns the File or directory not found error.

See Also

Tests Resources

Highlight search results