# How to Automate API Testing and CI/CD with AI

Source: https://www.youtube.com/watch?v=u-B9N7q66OE
Recap page: https://rapidrecap.app/video/u-B9N7q66OE
Generated: 2026-02-20T18:05:39.224+00:00

---
## Quick Overview

The demonstration shows how to automate API testing within a CI/CD pipeline by creating a GitHub Actions workflow file (postman.yaml) that runs a Postman collection against the User Permissions API, ultimately leading to 100% test passing after initial fixes were implemented via AI assistance.

**Key Points:**
- The user initialized a Postman workspace by selecting 'From Git repository' and connecting to a local directory containing API resources.
- The Postman collection for the 'User Permissions API' initially had failing tests, particularly concerning the 'Delete Users' endpoint returning HTML instead of JSON for a 404 error.
- The presenter used AI assistance within Postman to write comprehensive tests for each request, leading to a collection run summary showing 70 tests passed out of 87 before fixes.
- After implementing suggested fixes (including adjusting expected return formats for string arrays and ensuring JSON error responses), a subsequent collection run achieved 100% test pass rate across all requests.
- The final step involved creating a GitHub Actions workflow file (postman.yaml) in the .github/workflows folder to automatically run the Postman collection tests on every pull request targeting the main branch.
- The new workflow automatically installs Postman CLI, runs the collection tests using a secret POSTMAN_API_KEY, and uploads the results as artifacts, demonstrating full CI/CD integration.

![Screenshot at 00:14: The user selects 'From Git repository' during workspace creation, initiating the connection between the local codebase and the new Postman workspace.](https://ss.rapidrecap.app/screens/u-B9N7q66OE/00-00-14.jpg)

**Context:** This video provides a tutorial demonstrating the integration of Postman API testing with a Continuous Integration/Continuous Deployment (CI/CD) pipeline using GitHub Actions. The demonstration focuses on the 'User Permissions API' collection, showing how Postman's AI features can help in writing robust tests, diagnosing failures, and finally automating the execution of these tests within a standard GitHub workflow triggered by pull requests.

## Detailed Analysis

The demonstration begins by setting up a new Postman workspace directly from a Git repository, indicating a local-first development workflow. The presenter then navigates to the 'User Permissions API' collection within this workspace, which already contains several requests (GET, PUT, POST, DELETE). Upon running the collection tests initially, several failures are noted, particularly around response structure validation and error handling for endpoints like 'Delete Users' returning HTML instead of expected JSON for 404 errors. The presenter leverages Postman's AI capabilities to generate more comprehensive test coverage, specifically adding tests for every request. After running the collection again, the summary indicates significant improvement, with many tests passing, but critical issues remain, such as structure mismatches and endpoint errors. The recommended fixes involve updating expected string array formats and ensuring proper error responses. Once these issues are addressed (implicitly guided by the AI suggestions and subsequent test runs), the collection passes all 87 tests successfully. The final and most crucial step involves automating this testing process: the presenter creates a GitHub Actions workflow file named 'postman.yaml' in the '.github/workflows' directory. This YAML file is configured to run on 'push' to the 'main' branch or on 'workflow_dispatch'. The workflow job utilizes the 'postman-cli' to run the Postman collection, using the `POSTMAN_API_KEY` secret stored in GitHub. This setup ensures that the API tests execute automatically upon code changes, confirming the integration of testing into the CI/CD pipeline, and the final successful run validates the entire process.

### Workspace Setup

- Creating a workspace from a Git repository
- Selecting 'From Git repository' option
- Connecting to a local directory containing API resources

### Initial Test Run & Debugging

- Running the 'User Permissions API' collection tests
- Identifying failures in 'Delete Users' (HTML 404 response) and structure validation
- Using AI to write more comprehensive tests for all requests

### Test Fixes and Validation

- Achieving 100% pass rate after fixes (e.g., response structure and error handling adjustments)
- Final collection run passes all 87 tests successfully

### CI/CD Integration

- Creating a 'postman.yaml' workflow file in the '.github/workflows' folder
- Configuring the workflow to run on 'push' to 'main' or 'workflow_dispatch'
- Utilizing Postman CLI to execute the collection using the `POSTMAN_API_KEY` secret

### Next Steps

- Prompting AI for further actions like adding more test scenarios, setting up monitors, adding authentication tests, and creating documentation

![Screenshot at 00:08: The user is filling out the 'Create your workspace' form, selecting 'From Git repository' and naming the workspace 'user-permissions'.](https://ss.rapidrecap.app/screens/u-B9N7q66OE/00-00-08.jpg)
![Screenshot at 00:23: The Postman test results pane shows a detailed summary, highlighting the percentage of tests passed before and after applying fixes.](https://ss.rapidrecap.app/screens/u-B9N7q66OE/00-00-23.jpg)
![Screenshot at 00:47: The test coverage breakdown on the right side lists various categories like Performance, Structure, Data Types, Status Codes, Headers, Error Handling, and Security, indicating comprehensive testing.](https://ss.rapidrecap.app/screens/u-B9N7q66OE/00-00-47.jpg)
![Screenshot at 01:56: The final successful collection run summary shows 87 Total Tests, 87 Passed \(100%\), confirming successful integration and validation.](https://ss.rapidrecap.app/screens/u-B9N7q66OE/00-01-56.jpg)
![Screenshot at 02:53: The user is viewing the differences in the GitHub Pull Request, showing the newly added 'postman.yaml' file within the '.github/workflows' directory.](https://ss.rapidrecap.app/screens/u-B9N7q66OE/00-02-53.jpg)
