Test cases - Get multiple
- TypeScript
- Python
Get all test cases for a given pipeline with getTestCases()
.
You can also get test cases for a specific dataset within a pipeline using getTestCasesForDataset()
.
Get all test cases for a given pipeline with get_test_cases()
.
Example
typescript
constcases = awaitgetTestCases ('example-pipeline');for (consttestCase ofcases ) {console .log ('Case: ',testCase .name ,testCase .id );}constdatasetId = '123e4567-e89b-12d3-a456-426614174000';constdatasetCases = awaitgetTestCasesForDataset (datasetId );for (consttestCase ofdatasetCases ) {console .log ('Case in dataset: ',testCase .name ,testCase .id );}
python
import osimport gentracegentrace.init(api_key=os.getenv("GENTRACE_API_KEY"))cases = gentrace.get_test_cases(pipeline_slug="example-pipeline")for case in cases:print(case.get('id'))
Arguments
getTestCases()
pipelineSlug?: string
The slug of the pipeline to retrieve test cases for. Learn about pipelines here. Create a new pipeline here. If this is the only parameter specified, Gentrace will use the pipeline's golden dataset.
pipelineId?: string
The ID of the pipeline to retrieve test cases for. If this is the only parameter specified, Gentrace will use the pipeline's golden dataset.
Note: If both pipelineSlug
and pipelineId
are provided, pipelineId
will take precedence.
getTestCasesForDataset()
datasetId: string
The ID of the dataset to retrieve test cases for.
Note: getTestCasesForDataset()
is used specifically for retrieving test cases from a dataset, while getTestCases()
is used for retrieving test cases from a pipeline.
pipeline_slug: Optional[str]
The slug of the pipeline to retrieve test cases for. Learn about pipelines here. Create a new pipeline here.
pipeline_id: Optional[str]
The ID of the pipeline to retrieve test cases for.
dataset_id: Optional[str]
The ID of the dataset to retrieve test cases for.
Note: If multiple parameters are supplied, the dataset_id
will be prioritized over pipeline_id
and pipeline_slug
.
Return value
Returns an array of TestCases
.
🛠️ TestCase
The TestCase
type represents the structure of a test case. Below are the fields of the TestCase
type.
id: string (UUID)
createdAt: string (ISO 8601)
archivedAt?: string (ISO 8601)
updatedAt: string (ISO 8601)
expectedOutputs?: object
An object representing the expected outputs for the test case.
inputs: object
An object containing input data for the test case.
name: string
pipelineId: string (UUID)
datasetId: string (UUID)