While unit testing focuses on individual requests and responses, end-to-end testing puts these pieces together to test complex user journeys. End-to-end testing touches multiple components in your application and ensures the entire system works as expected. It also identifies issues in real-world workflows before they can impact users.
End-to-end testing covers complete application flows from start to finish. Each flow represents the sequence of actions a user will take in the application and can involve multiple endpoints and APIs. By simulating complex user interactions, end-to-end testing can identify bottlenecks, integration errors, and problems with user experience.
With Postman, you can use collections to send requests in a specific order and chain requests together. You can also pass data between requests. This enables you to validate real-world usage scenarios and test workflows involving various system components. After running your end-to-end tests manually or automatically, you can view the results in Postman to find out which tests passed or failed.
View an example that shows how you can use Postman to set up and run end-to-end tests for your API. To try out this collection template, select End-to-end testing.
To set up end-to-end tests for your application in Postman, use the following framework:
The basic unit of testing is an API request. Each request tests a specific piece of functionality by calling an API endpoint. You can configure request authorization as needed. You can also send any required test data such as parameters, headers, and body data. Learn more about creating and sending requests.
Write scripts to add test logic to requests. For each request, you can write test scripts to check if the expected data is received when the request is sent. You can test and validate the response code, headers, body data, and more. Learn more about writing test scripts.
Organize suites of tests using collections. You can save multiple requests in a collection and organize them into categories. Collections enable you to run and rerun a group of tests in the order you choose. You can also upload data files to run tests multiple times using different data each time. Learn more about creating collections.
You can also add a test suite to an API in Postman. Learn more at Test your API using test collections and CI tools.
Use scripts to build complex workflows. With scripts, you can process response data from one request and use it as an input in the next request to test data flow. You can also use scripts to dynamically control the order of requests. For example, send a request to create a user account, then send another request to get the new account and verify that it was created. Learn more about processing data and building workflows with scripts.
Run your tests in multiple environments. In Postman, environments are groups of related variables you can use in your requests. Environments enable you to reuse the same suite of tests in different contexts. For example, if your test and production setups require different URLs or configuration values, you can use Postman environments to switch between them. Learn more about working with environments and variables.
Simulate other systems with mock servers. You can test how your application interacts with other APIs and systems without having to connect to the actual resources. Instead, you can use Postman to set up a mock server that simulates the behavior of a real API server by accepting requests and returning responses. Learn more about setting up mock servers.
After setting up your end-to-end tests in Postman, you can run them in the following ways:
Run tests manually. To run a single test, open a request and send it. You can view the test results in the workbench. To run an entire test suite, use the Collection Runner. As the collection runs, Postman displays the test results in real time. Learn more about running tests manually in Postman.
Automate tests on a schedule. You can run test suites automatically on a schedule using the Collection Runner. Get notifications when tests fail, and view test results in Postman. Learn more about running API tests on a schedule in Postman.
Run tests in your CI/CD pipeline. You can run tests as part of your regular application build process using the Postman CLI. Run your test suites after every code push and view test reports in Postman. Learn more about running API tests in your CI/CD pipeline.
Last modified: 2024/05/01