Test your API · Lesson 6 of 20

Run a whole collection

Send every request in order, feed it test data, read the report and take the same run to CI.

Beginner · 2 min · Updated

Run every request in a collection with its tests and watch the results, status codes and timings arrive.
Run every request in a collection with its tests and watch the results, status codes and timings arrive.

Sending requests one at a time is fine while you build. To check that the whole API still works, run the collection: every request in order, with its scripts and tests, and one report at the end.

Start a run

  1. Right-click a collection and choose Run collection (or click Runner in the bottom bar).
  2. Pick the environment to run against.
  3. Untick requests you want to skip, or drag them into a different order.
  4. Click Run.

Results stream in as each request finishes: status, time, size and every test. Filter to Failed to see only what broke, and click a row to see the full request, response, console output and test messages.

Before you start, the runner checks the selected requests for variables that nothing defines or that are empty (for example {{baseUrl}} with no environment picked) and warns you, so a run never fails for a silly reason.

Run with test data

To try the same requests with many inputs, use a data file:

CSV
email,password,expected
ada@example.com,correct-horse,200
nobody@example.com,wrong,401

Choose it under Data file. The runner does one iteration per row, and each column is a variable: {{email}}, {{password}}. In a test, swc.iterationData.get('expected') reads the expected status for that row.

Useful options

  • Iterations: repeat the run a number of times.
  • Delay: wait between requests, to stay under rate limits.
  • Stop the run: never, on the first failure, on the first failed test, or on the first error.
  • Keep variable values after the run: write tokens and ids the scripts set back to your environment.
  • Save responses: keep bodies in the results (turn it off for very long runs).

Reports

When the run ends, download it as JSON, JUnit XML (for CI dashboards) or HTML (to share). Past runs are listed under History in the runner.

Take it to CI

Click Run in CI in the runner. Pick GitHub Actions, GitLab CI, Jenkins, Azure Pipelines or CircleCI, and Swastik Codes writes the pipeline file for you. It runs this collection with the swc command-line tool on every push and publishes the JUnit report. Lesson 9 explains the details.

What you learned

  • Run collection sends every request in order and reports every test.
  • Data files turn one run into many; reports and Run in CI take the same checks into your pipeline.

Next: compare responses to spot what changed.

Try it on your own API

Swastik Codes runs in the browser and is free to use. Create an account to send requests, sync your workspaces and invite your team.