Skip to main content

API Tests

API tests check your application's endpoints directly, without a browser. You import an OpenAPI specification, pick the user stories and endpoints to cover, and TestFlair generates the tests. You then refine them in an editor and export them to Postman or Excel.

note

TestFlair doesn't run API tests yet. Generate and edit them here, then export them as a Postman collection to run in Postman or your own tooling.

  • Who can generate and edit Project Admin, QA Manager, Tester (and workspace Owners and Coordinators). Everyone on the project can view them
  • Costs Generation uses Flairs
  • Where Project → API Tests
  • You need User stories, and an OpenAPI specification (JSON or YAML, up to 10 MB)
  1. YouSelect user stories
  2. YouImport OpenAPI spec and select endpoints
  3. AIAI generates API tests
  4. YouReview and refine in the editor
  5. Export to Postman or Excel
  6. Your toolsRun in Postman or your CI
TestFlair generates and stores the tests; running them happens in the tool you export to.

Importing an OpenAPI specification​

TestFlair reads your endpoints from an OpenAPI specification instead of asking you to type them in.

  1. Open API Tests and click the ⋯ button in the header.
  2. Choose Import OpenApi Spec.
  3. Drop or browse for your specification file (.json or .yaml, up to 10 MB).

TestFlair parses the file and groups its endpoints. Each endpoint keeps its method: GET, POST, PUT, PATCH or DELETE. Choose View OpenApi Spec from the same menu to browse the endpoints of the most recently imported specification.

Specifications are versioned: importing again adds a new version rather than overwriting the old one, and tests generated earlier keep pointing at the endpoints they were built from.

You can also import a specification during generation, in the wizard's second step.

Generating API tests​

  1. Click Generate APIs (or Generate on the empty page).
  2. Select user stories: tick the user stories the tests should cover. Use the eye icon to read a story.
  3. Click Next.
  4. Select endpoints: import a specification if the project has none, then tick the endpoints that relate to those stories. Import OpenAPI loads a newer specification.
  5. Click Generate APIs.

Keep the window open while Generating API Tests... is shown. When it finishes, it tells you how many tests were generated.

Functional and end-to-end tests​

TypeWhat it isEditor tabs
FunctionalOne request to one endpointOverview, Parameters, Header, Body, Scripts, Variables
E2EAn ordered chain of requests, for a flow across several endpointsOverview, Steps, Header, Scripts, Variables

In an E2E test, the Header, Scripts and Variables tabs apply to the whole test, and each step has its own endpoint, Parameters, Header, Body, Scripts and Variables.

What a request is made of​

  1. Variables
  2. Pre-request script
  3. Requestmethod, URL, parameters, headers, body
  4. Post-request script
  5. Assertion
The parts you can edit for each request, in the order they apply when the exported test runs.
PartWhat you set
OverviewTitle (required), Description and the Assertion: what a correct response looks like
ParametersQuery parameters as key/value pairs
HeaderRequest headers as key/value pairs
BodyThe request body, in a JSON editor
ScriptsA Pre-request and a Post-request script in JavaScript. The editor autocompletes Postman's pm scripting API, so the scripts carry over to Postman
VariablesKey/value pairs used across the request. Values the AI produced carry an AI Generated badge

Classification​

Each test has a Category (Positive, Negative or Edge), a Type (Functional or E2E) and a Priority (Low, Medium or High), shown as badges on the test.

Working with the list​

The list shows Total API Tests, Positive Tests, Negative Tests and Edge Cases at the top, with columns Test Name, Method, Type, Category and Priority.

  • Switch between Functional, E2E and All with the toggle.
  • Search by name, or filter by type, method, category and priority.
  • Each row's menu has Edit, Export, Duplicate and Delete.
  • Select rows to delete, export or duplicate several at once. Duplicating is a quick way to build a negative test from a positive one.

Editing a test​

Click a row to open the test in a drawer. Click Edit, make your changes, then Save. If you close with unsaved changes, TestFlair asks before discarding them. The drawer's ⋯ menu has Duplicate and Delete, and Export downloads the test as a Postman collection.

Maximize the drawer to open the test as a full page, with more room for long bodies and scripts and a comments panel beside the editor. See Collaboration.

Exporting​

Click Export in the header and pick a format:

FormatWhat you get
Excel fileAll the project's API tests in a spreadsheet, for review or sharing
JSON fileA Postman Collection (v2.1) you can import into Postman and run

Troubleshooting​

My import was rejected

  • The file must be a valid OpenAPI specification in JSON or YAML, under 10 MB. Validate it first: a spec that a viewer renders may still be missing fields TestFlair needs.

Generation produced few or no tests

  • Make sure the user stories you picked describe behaviour the selected endpoints actually cover. Generation works from the story text, so vague stories produce little.

Generate APIs or Import OpenApi Spec is disabled

  • Your role can view API tests but not create them, or import specifications. Ask a Project Admin.

Next Steps​

  • User Stories — The requirements API tests are generated from
  • Test Cases — Browser-level tests for the same project
  • Collaboration — Comment on an API test with your team
  • Billing — Check your Flair balance