Test cases - Create multiple
- TypeScript
- Python
Create multiple test cases with createTestCases()
.
Create multiple test cases with create_test_cases()
.
Arguments
payload
The payload argument is a JavaScript array payload of the new test cases (type CreateMultipleTestCase
). In our API, this
payload is used to create the new test cases.
Types
🛠️ CreateMultipleTestCase
This type defines the structure for creating multiple test cases. Below are the fields of the CreateMultipleTestCases
type.
pipelineSlug
The slug (unique identifier) for the pipeline. It is a string that represents a simplified, URL-friendly version of a pipeline name.
testCases
An array of test cases to create. Each test case has the type CreateMultipleTestCasesTestCasesInner
.
🛠️ CreateMultipleTestCasesTestCasesInner
This type defines the structure for creating a single test case. Below are the fields of the CreateMultipleTestCasesTestCasesInner
type.
name?
The name of the test case. It is a string that identifies the test case.
inputs?
The input data for the test case, formatted as a JSON object. The keys are strings and the values can be of any type.
expectedOutputs?
The expected outputs for the test case, also formatted as a JSON object. This can be null
if there are no expected outputs defined for the test case.
Return value
creationCount
The number of test cases created as a number.
Example
typescript
constcreationCount = awaitcreateTestCases ({pipelineSlug : "example-pipeline",testCases : [{name : `TC 1`,inputs : {a : 1,b : 2 },expectedOutputs : {c : 3 },},],});console .log ("Created test case count: ",creationCount );
python
import osimport gentracegentrace.init(api_key=os.getenv("GENTRACE_API_KEY"))creation_count = gentrace.create_test_cases(pipeline_slug="example-pipeline",payload=[{"name": "Batman -> Black Window #1","inputs": {"query": "describing an ethical dilemma you encountered and asking "+ "for feedback","sender": "Batman","receiver": "Black Widow",},"expectedOutputs": {"value": "Dear Natasha,\n I have run into a problem..."},},{"name": "Superman -> Wonder Woman #3","inputs": {"query": "desperately asking for backup to a tough situation you am"+ " in","sender": "Superman","receiver": "Wonder Woman",},"expectedOutputs": {"value": "Subject: Urgent Assistance Required: Backup Needed"+ " Immediately"},},],)print(creation_count)