Skip to main content

Shared Preconditions

The shared preconditions endpoints allow you to manage reusable test preconditions that can be referenced across multiple test cases. Shared preconditions consist of a title and text content that describes the initial state or setup required before executing test cases.

About Shared Preconditions​

Shared preconditions are reusable precondition templates that can be used in multiple test cases. They consist of:

  1. Title: A descriptive name for the shared precondition (required, minimum 1 character)
  2. Text: The actual precondition content in HTML format (required, minimum 1 character)

When a shared precondition is used in a test case, it provides consistent setup instructions. Updates to a shared precondition automatically propagate to all test cases that reference it.

important
  • Shared preconditions must have both a title and text content
  • The title of a shared precondition must be unique within a project
  • Shared preconditions are versioned - updates create new versions while preserving old ones
  • Deleted preconditions are marked with a deletedAt timestamp but remain in the data structure

List Shared Preconditions​

GET/api/public/v0/project/{project_id}/shared-precondition

Retrieves all shared preconditions within a project, optionally sorted and with additional fields included.

Path Parameters​

  • project_id: The project identifier (can be either the project code or UUID)

Query Parameters​

All query parameters are optional.

ParameterTypeDescriptionAllowed ValuesExample
sortFieldstringField to sort bycreated_at, titlesortField=title
sortOrderstringSort order (requires sortField; default: desc)asc, descsortOrder=asc
includestringInclude additional fields in the response which are omitted by defaulttcaseCountinclude=tcaseCount
tip
  • Use include=tcaseCount to see how many test cases reference each shared precondition
  • Sorting by created_at shows the most recently created preconditions first (with desc) or oldest first (with asc)
  • Sorting by title provides alphabetical ordering
  • If no sortField is specified, the default sort is by title in ascending order

Example Request​

Fetch all shared preconditions​

curl \
-H "Authorization: ApiKey your.api.key.here" \
https://your-company.your-region-code.qasphere.com/api/public/v0/project/BD/shared-precondition

Fetch all shared preconditions sorted by title in ascending order​

curl \
-H "Authorization: ApiKey your.api.key.here" \
https://your-company.your-region-code.qasphere.com/api/public/v0/project/BD/shared-precondition?sortField=title&sortOrder=asc

Fetch all shared preconditions sorted by creation date (newest first)​

curl \
-H "Authorization: ApiKey your.api.key.here" \
https://your-company.your-region-code.qasphere.com/api/public/v0/project/BD/shared-precondition?sortField=created_at&sortOrder=desc

Fetch all shared preconditions with test case count included​

curl \
-H "Authorization: ApiKey your.api.key.here" \
https://your-company.your-region-code.qasphere.com/api/public/v0/project/BD/shared-precondition?include=tcaseCount

Response Fields​

Array<{                // List of shared precondition objects
projectId: string // Unique identifier of the project
id: number // Unique identifier of the shared precondition
version: number // Version of the shared precondition
title: string // Title of the shared precondition
type: string // Type of the precondition (always "shared" for shared preconditions)
text: html // Text content of the precondition (HTML format)
isLatest: boolean // Whether this is the latest version of the precondition
createdAt: string // Precondition creation time (ISO 8601 format)
updatedAt: string // Precondition updation time (ISO 8601 format)
deletedAt?: string // Date the precondition was deleted on (ISO 8601 format)
tcaseCount?: number // Number of test cases using this shared precondition (only included if requested)
}>

Example Response​

[
{
"projectId": "2HKj57k3z_YXYQVTdnPqrs8",
"id": 1,
"version": 2,
"title": "User is logged in",
"type": "shared",
"text": "<p>The user has valid credentials and is authenticated in the system</p>",
"isLatest": true,
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-20T14:45:00.000Z"
},
{
"projectId": "2HKj57k3z_YXYQVTdnPqrs8",
"id": 2,
"version": 1,
"title": "Application is running",
"type": "shared",
"text": "<p>The application server is running and accessible</p>",
"isLatest": true,
"createdAt": "2025-01-16T09:15:00.000Z",
"updatedAt": "2025-01-16T09:15:00.000Z",
"tcaseCount": 15
},
{
"projectId": "2HKj57k3z_YXYQVTdnPqrs8",
"id": 3,
"version": 1,
"title": "Database is initialized",
"type": "shared",
"text": "<p>The database contains the required test data</p>",
"isLatest": true,
"createdAt": "2025-01-17T11:20:00.000Z",
"updatedAt": "2025-01-17T11:20:00.000Z",
"tcaseCount": 3
}
]

Get Shared Precondition​

GET/api/public/v0/project/{project_id}/shared-precondition/{shared_precondition_id}

Get details of a single shared precondition using its ID.

Path Parameters​

  • project_id: The project identifier (can be either the project code or UUID)
  • shared_precondition_id: The shared precondition identifier (numeric ID)

Example Request​

curl \
-H "Authorization: ApiKey your.api.key.here" \
https://your-company.your-region-code.qasphere.com/api/public/v0/project/BD/shared-precondition/1

Response Fields​

{
projectId: string // Unique identifier of the project
id: number // Unique identifier of the shared precondition
version: number // Version of the shared precondition
title: string // Title of the shared precondition
type: string // Type of the precondition (always "shared" for shared preconditions)
text: html // Text content of the precondition (HTML format)
isLatest: boolean // Whether this is the latest version of the precondition
createdAt: string // Precondition creation time (ISO 8601 format)
updatedAt: string // Precondition updation time (ISO 8601 format)
deletedAt?: string // Date the precondition was deleted on (ISO 8601 format)
}

Example Response​

{
"projectId": "2HKj57k3z_YXYQVTdnPqrs8",
"id": 1,
"version": 2,
"title": "User is logged in",
"type": "shared",
"text": "<p>The user has valid credentials and is authenticated in the system</p>",
"isLatest": true,
"createdAt": "2025-01-15T10:30:00.000Z",
"updatedAt": "2025-01-20T14:45:00.000Z"
}