Create test cases with useful steps
Use this workflow when your integration creates structured test definitions from a service catalog, specification or another system.
Prepare the project and suite
Section titled “Prepare the project and suite”Use an existing project and suite that the token owner can write to. Get the suite ID from the suite reference or from the TestCollab app.
The suite must belong to the same project as the new case. Replace the example IDs before running the code.
Create a case
Section titled “Create a case”import { createConfiguration, TestCasesApi } from '@testcollab/sdk';
const api = new TestCasesApi(createConfiguration(process.env.TESTCOLLAB_TOKEN!));const testCase = await api.createTestCase({ testCasePayload: { project: 123, suite: 456, // An existing suite in the same project. title: 'A customer can complete checkout', priority: 2, description: '<p>A customer pays with a valid card.</p>', steps: [ { step: 'Add a product to the basket', expectedResult: 'The basket contains the product' }, { step: 'Complete checkout with a valid card', expectedResult: 'An order confirmation is shown' }, ], },});
console.log('Created case:', testCase.id);The SDK converts expectedResult to the API field automatically. The response’s id is the repository case ID; store it if the integration will update or reference the case later.
Add more context
Section titled “Add more context”Use existing tag IDs and custom-field definitions when your integration needs classification. Fetch those definitions first rather than guessing an option’s ID or sending a display label where the API expects an ID.
A case can also have a default assignee. When you include that case in a plan, normal assignment preserves existing/default assignments unless you explicitly override them.
Keep repeated imports predictable
Section titled “Keep repeated imports predictable”Keep a mapping between your source record and the created TestCollab case ID. On the next sync, update that case instead of creating another one with the same title.
If feature files own the definitions, use BDD sync instead of recreating those cases through this workflow.
Continue
Section titled “Continue”Include your cases in a test plan to prepare them for execution.