Test cases - Create single
- TypeScript
- Python
Create a single test case with createTestCase()
.
Create a single test case with create_test_case()
.
Arguments
payload
The payload argument is a JavaScript payload of the new test case payload (type CreateTestCase
). In our API, the payload
is used to create the new test case.
Types
🛠️ CreateTestCase
This type defines the structure for creating a new test case. Below are the fields of the CreateTestCase
type.
pipelineSlug?
The slug (unique identifier) for the pipeline. It is a string that represents a simplified, URL-friendly version of a pipeline name.
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
caseId
The ID of the created test case as a UUID string.
Example
typescript
constcaseId = awaitcreateTestCase ({pipelineSlug : "example-pipeline",name : "Example test case",inputs : {a : 1,b : 2 },expectedOutputs : {c : 3 },});console .log ("Case ID: ",caseId );
python
import gentraceimport osgentrace.init({"api_key": os.getenv("GENTRACE_API_KEY")})case_id = gentrace.create_test_case(pipeline_slug="guess-the-year",payload={"name": "Test case 1","inputs": {"a": "1", "b": "2"},"expectedOutputs": {"value": "3"},},)print("Case ID: ", case_id)