Skip to navigation

Run a performance test with a mock

View as Markdown

You can redirect the collection’s requests to a mock during a performance test using the Mock tab in the Collection Runner. For each base URL in the collection, you can select a different mock. Requests to a mapped base URL go to the mock instead of the real endpoint, so the test generates load against mock responses rather than sending that traffic to a real service.

The Mock tab is available in the Postman desktop app only, in Cloud View, and only when you select the App or Postman CLI run method. (Performance tests aren’t available in Local View.) Mocks apply to these local runs only. You can’t redirect requests to a mock on a cloud run.

Select a mock for a performance run

Run a performance test with a mock to generate load against mock responses instead of reaching the real endpoints the collection calls. When you start the run, Postman redirects requests that match a selected base URL to the mock.

  1. Click Items icon Items in the left sidebar.
  2. Click Collections and select the collection you want to run.
  3. Click Run icon Run.
  4. Under Run type, select Performance.
  5. Under Run method, select App or Postman CLI.
  6. Configure the performance test settings as needed.
  7. Click the Mock tab.
  8. For each base URL in the collection, use the Select mock dropdown list to choose a mock. To create a new mock, select Add icon Create mock from the dropdown list. Postman identifies all requests using that base URL and uses them in the mock’s implementation.
  9. (Optional) Next to each mock dropdown list, select a scenario with specific request handling code, endpoints, and conditions. To learn more about scenarios, see Manage scenarios in a mock.
  10. Start the run. If you selected the App run method, click Start run. If you selected the Postman CLI run method, copy the generated command and run it in your terminal.

You can also redirect requests to a mock without the Mock tab by using the --use-mock option with the postman performance run command, such as in a CI/CD pipeline. Like the Mock tab, this applies to local runs only.

After the run completes, you can view performance test metrics for the run.