API tests

When is Postman enough, and when are API tests in code worthwhile?

Postman works well for exploring APIs and for automated tests. Request collections can run in CI, where application changes are checked automatically. Tests in code are particularly useful when a team needs more involved data setup, shared helper functions and maintenance in the same language as the application. Base your decision on how the suite is maintained and operated, and on the people who will maintain it.

When a collection only works on one computer

Consider this illustrative scenario: a tester has a collection for creating an order, fetching its details and cancelling it. Before a release, they run it with their own account. The collection passes, but a colleague does not know which data it needs, where to obtain a token or which collection version is current. After an API change, the local copy is fixed while the automated run still uses an older version.

The team needs a shared process. The same problem can affect Python tests if only their author can run them. Before replacing the tool, check where the authoritative suite version lives, who approves changes and who responds to failures. If those responsibilities are undefined, a rewrite will not resolve them.

Also separate requests saved for debugging from a regression suite. Regression tests repeatedly check behaviour that should continue working after a change. A request saved with a note saying “this worked for me yesterday” may still lack a clear expected result or prepared data.

What Postman supports and where versions matter

Postman supports scripts, response assertions and automated collection runs. Its current version 12 documentation also describes Native Git, where you work with local files in a repository. Version control and change review in Git are therefore not, by themselves, reasons to leave Postman. Check whether your particular installation and collection format support this workflow.

An older suite may use Newman in its pipeline. The migration documentation states that Newman is no longer maintained and supports the v2.1 JSON collection format. It does not support the v3 YAML format used by Native Git. Postman CLI also supports v3 and is the recommended runner for current collections. An existing v2.1 suite does not automatically stop working, but further development needs a compatible execution plan.

Assess local execution and cloud services separately. Postman CLI includes a workflow for projects without an account. According to the collection run documentation, signed-in runs using a cloud ID or a linked local collection upload results to Postman under the documented conditions. Results from an unlinked local file are not uploaded. This is not a complete description of all network communication by the tool. For an internal API, agree where definitions, data and results may be stored.

Choosing a workflow that fits the team

Try one representative scenario, including its data and CI execution, before deciding. The number of endpoints alone is not enough. Ten requests with complicated dependencies may need more maintenance than a large but straightforward collection.

Requirement Postman collection Tests in code
Interactive API exploration Edit and inspect requests and responses in the client. You can continue using an API client for convenient exploration.
Reviewing changes in Git Check the supported format and chosen Git workflow. Review tests alongside the application change.
Multiple inputs for one scenario Data iterations and shared scripts are suitable options. Parametrization can separate inputs from test logic.
Complicated data setup and cleanup Check script readability and support in the runner. Compose setup and cleanup helper functions to suit the project.
Handing over maintenance The team needs to understand the collection and its scripts. The team needs to know the language, libraries and test framework.

Staying with Postman makes sense when collections cover the required scenarios, changes are reviewed and automated runs can be reproduced reliably. Consider moving to code when scripts duplicate substantial logic, data setup is complicated or the team already maintains similar tests in its development environment.

Another option is file-based collections in Bruno, which can run through Bruno CLI. This approach may suit a team that wants an API client and files in Git. Check script compatibility and required features here too. When comparing costs, include maintenance, training, runner operation and the terms of the services you use.

Which assertions to carry over

First, write down what each scenario should protect. For an order, checking a successful HTTP status is not enough. Depending on the agreed behaviour, the test should also check the identifier, items and amount, then fetch the created order and compare the stored data. For cancellation, establish which status the order should receive and what must remain unchanged.

Add negative scenarios and boundary cases, such as a missing required field, an invalid input or a second user trying to access someone else’s order. Define the expected status and error response from the rules of the particular API. Even the right tool will not help if a test accepts every response or only checks that the server replied.

In Python with pytest, account and order setup can be moved into fixtures, which provide shared test setup and cleanup. Parametrization runs the same scenario with multiple inputs. These features do not replace coverage design. If several services use the API, also consider contract testing, which checks the agreed interface between them.

Migrating one scenario at a time

Start with a small suite that includes a normal request, a failure and work with data. The article on REST API testing develops assertion design in more detail.

  1. Record requests, assertions, variables and dependencies. Identify the collection version, environment and source of credentials.
  2. Migrate one complete scenario, including setup and cleanup. A colleague must be able to create its data without the author’s local configuration.
  3. Run the original and new versions against the same API version using separate test data. Compare what they actually check and how they report errors.
  4. Add the pilot to CI. Check network access, certificates, permissions and the pipeline’s response to a failing test.
  5. Migrate further scenarios after that review. For each one, specify which version is authoritative so the two suites do not gradually diverge.

When moving between Postman formats, use a supported migration process. When moving to Bruno, collection import can translate common scripting APIs, but not every package or behaviour. Check imported scenarios functionally too. Successfully opening a file does not confirm that the original assertions have been preserved.

Why a test passes locally and fails in CI

Local success may depend on a saved token, a previous request or an existing order. Start CI runs from a clearly defined state. Use dedicated test accounts and data created for the particular run. When running tests concurrently, isolate the data so one test cannot cancel another test’s order.

Define execution rules too. A short suite of critical scenarios can run when reviewing changes, with broader regression runs scheduled and performed before a release. Adapt the selection to the risk of the change and environment availability. Agree in advance which failures will stop progress towards a release and who can approve an exception. Otherwise, the pipeline may execute tests while their results never inform the release decision.

Authentication must work without manual confirmation by a tester. Supply secrets through the CI mechanism intended to manage them, and keep them out of the repository. If a collection uses pm.vault, the Postman Vault documentation states that neither Postman CLI nor Newman supports those methods. Prepare another way to supply secrets for automated execution.

When a run fails, first distinguish an application defect from an unavailable environment, an expired token or a data problem. Rerunning can help diagnosis, but should not conceal an unclear result. Preserve the scenario name, expectation and actual result in the report without sensitive data. Check the available output formats for both the selected runner and collection format.

Checking whether the new workflow helps

A finished suite can run from a clean environment by following its documentation. It has an owner and a reviewed change history. In a trial test, deliberately change an expectation to an incorrect value. Check that the test fails, CI reports a failure and the team receives a useful result. Check whether the configuration suppresses the runner’s exit code.

During maintenance, track whether failures can be diagnosed and whether API changes are accompanied by corresponding test changes. The benefit is a repeatable check with a clear result and less dependence on one person. The number of migrated tests alone does not establish quality.

The next step is to compare one real scenario in the current and proposed workflows. If Postman meets the team’s needs, improve how it is operated. If the pilot reveals specific limitations in maintenance or data handling, migrate scenarios gradually to a more suitable solution.

Related topics

You might also be interested in

You can detect errors in the business logic more quickly directly through the API

Functional, integration and contract testing of REST, SOAP or GraphQL interfaces with the possibility of connection to the CI/CD pipeline.