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:
- Title: A descriptive name for the shared precondition (required, minimum 1 character)
- 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.
- 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
deletedAttimestamp but remain in the data structure
List Shared Preconditions
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.
| Parameter | Type | Description | Allowed Values | Example |
|---|---|---|---|---|
sortField | string | Field to sort by | created_at, title | sortField=title |
sortOrder | string | Sort order (requires sortField; default: desc) | asc, desc | sortOrder=asc |
include | string | Include additional fields in the response which are omitted by default | tcaseCount | include=tcaseCount |
- Use
include=tcaseCountto see how many test cases reference each shared precondition - Sorting by
created_atshows the most recently created preconditions first (withdesc) or oldest first (withasc) - Sorting by
titleprovides alphabetical ordering - If no
sortFieldis specified, the default sort is bytitlein 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 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"
}