> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/continuous-integration/api-reference/test-cases.md).

# Test Cases

Test cases reported for a pipeline execution

## List test cases for a pipeline execution

> Returns the JUnit test cases that a pipeline execution reported, one page at a time.

```json
{"openapi":"3.0.0","info":{"title":"Harness Test Intelligence API","version":"1.0.0"},"tags":[{"name":"test-cases","description":"Test cases reported for a pipeline execution"}],"servers":[{"url":"https://app.harness.io/gateway/ti-service","description":"Harness SaaS"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"x-api-key","description":"Harness Personal Access Token with the View permission on the pipeline."}},"schemas":{"TestCases":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/ResponseMetadata"},"content":{"type":"array","items":{"$ref":"#/components/schemas/TestCase"}}}},"ResponseMetadata":{"type":"object","properties":{"totalPages":{"type":"integer","description":"Total number of pages for the query."},"totalItems":{"type":"integer","description":"Number of test cases that match the query, across all pages."},"pageItemCount":{"type":"integer","description":"Number of test cases in this page."},"pageSize":{"type":"integer","description":"Page size that Harness applied."}}},"TestCase":{"type":"object","properties":{"name":{"type":"string","description":"Test case name from the JUnit report."},"class_name":{"type":"string","description":"Class name from the JUnit report."},"file_name":{"type":"string","description":"File name from the JUnit report."},"suite_name":{"type":"string","description":"Test suite name from the JUnit report."},"result":{"$ref":"#/components/schemas/Result"},"duration_ms":{"type":"integer","format":"int64","description":"Duration of the test case in milliseconds."},"stdout":{"type":"string","description":"Standard output captured while the test ran. It can be large and may be truncated."},"stderr":{"type":"string","description":"Standard error captured while the test ran. It can be large and may be truncated."},"flaky":{"type":"boolean","description":"Whether Harness marks the test as flaky."},"quarantine":{"type":"boolean","description":"Whether the test is currently quarantined."},"problematic":{"type":"boolean","description":"Whether the test is currently marked problematic."},"artifacts":{"type":"array","description":"Files captured while the test ran, such as Playwright traces, videos, and screenshots. Omitted when the test has none. Entries are references to files in Harness Artifacts, not download links.","items":{"$ref":"#/components/schemas/TestArtifact"}}}},"Result":{"type":"object","properties":{"status":{"$ref":"#/components/schemas/TestCaseStatus"},"message":{"type":"string","description":"Failure or error message, when present."},"type":{"type":"string","description":"Failure or error type, when present."},"desc":{"type":"string","description":"Failure or error description, when present."}}},"TestCaseStatus":{"type":"string","description":"Outcome of the test case. `skipped_by_ti` means Test Intelligence skipped the test.","enum":["passed","skipped","skipped_by_ti","error","failed"]},"TestArtifact":{"type":"object","required":["type","path","size"],"properties":{"type":{"type":"string","description":"Kind of artifact.","enum":["trace","video","screenshot"]},"path":{"type":"string","description":"Path of the file in the test attachments folder of the run, for example `<stepId>/<test-dir>/trace.zip`."},"file_name":{"type":"string","description":"File name, returned only if the upload included one."},"size":{"type":"integer","format":"int64","description":"File size in bytes."},"attempt":{"type":"integer","description":"Retry attempt that produced the file. Omitted for the first attempt."}}},"Problem":{"type":"object","description":"Error response in the `application/problem+json` format.","required":["type","title","status","code"],"properties":{"type":{"type":"string","description":"URI that identifies the problem, in the form `https://harness.io/problems/ti-service/{code}`."},"title":{"type":"string","description":"Short summary of the problem."},"status":{"type":"integer","description":"HTTP status code."},"detail":{"type":"string","description":"Explanation specific to this request."},"code":{"type":"string","description":"Machine-readable error code.","enum":["invalid_identifier","invalid_page_size","unauthenticated","forbidden","dependency_unavailable"]},"requestId":{"type":"string","description":"Value of the `X-Request-ID` request header, when you sent one."}}},"Error":{"type":"object","properties":{"error_msg":{"type":"string","description":"Details about the error."}}}}},"paths":{"/api/v1/test-cases":{"get":{"tags":["test-cases"],"summary":"List test cases for a pipeline execution","operationId":"listTestCases","description":"Returns the JUnit test cases that a pipeline execution reported, one page at a time.","parameters":[{"name":"accountId","in":"query","required":true,"description":"Harness account identifier.","schema":{"type":"string"}},{"name":"orgId","in":"query","required":true,"description":"Organization identifier.","schema":{"type":"string"}},{"name":"projectId","in":"query","required":true,"description":"Project identifier.","schema":{"type":"string"}},{"name":"pipelineId","in":"query","required":true,"description":"Pipeline identifier. Harness checks your View permission on this pipeline.","schema":{"type":"string"}},{"name":"buildId","in":"query","required":true,"description":"Pipeline execution number.","schema":{"type":"string"}},{"name":"stageId","in":"query","required":false,"description":"Return only the test cases from this stage.","schema":{"type":"string"}},{"name":"stepId","in":"query","required":false,"description":"Return only the test cases from this step. You can use it with or without `stageId`.","schema":{"type":"string"}},{"name":"pageSize","in":"query","required":false,"description":"Number of test cases to return in a page.","schema":{"type":"integer","minimum":1,"maximum":1000,"default":10}},{"name":"pageIndex","in":"query","required":false,"description":"Zero-based index of the page to return.","schema":{"type":"integer","minimum":0,"default":0}}],"responses":{"200":{"description":"One page of test cases.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TestCases"}}}},"204":{"description":"The query matched no test cases. The response has no body, so do not parse one."},"400":{"description":"A required identifier is missing or invalid, `pageSize` is outside 1 to 1000, or the query string cannot be parsed. A non-integer `pageIndex` also returns `400`, but with an `application/json` body that has an `error_msg` field.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"401":{"description":"The `x-api-key` header is missing, or the token is invalid.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"403":{"description":"The token does not have the View permission on the pipeline, or the API is not enabled for your account. Contact Harness Support to enable the API.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"429":{"description":"Too many requests from your IP address. Back off and retry, for example with exponential backoff and jitter. To reduce the number of requests, use a larger `pageSize`. The body is HTML, not JSON."},"500":{"description":"An error occurred while reading the results. The body is `application/json` with an `error_msg` field.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Harness could not check your permissions. Retry the request.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}}}}}}}
```
