CHAPTER 15
Intermediate
CI/CD and DevOps Testing
Updated: May 16, 2026
35 min read
# CHAPTER 15
CI/CD and DevOps Testing
1. Introduction
In the old days, developers would write code for 3 months, hand it to QA on a CD-ROM, and QA would spend 1 month testing it. This slow, siloed approach is dead. Today, top tech companies deploy code to production 50 times a day. How is this possible without breaking everything? The answer is CI/CD (Continuous Integration and Continuous Deployment) driven by rigorous DevOps testing. In this chapter, we will bridge the gap between QA and DevOps. We will learn how automated tests are no longer run manually on a tester's laptop, but are triggered automatically by cloud servers every single time a developer writes a line of code.2. Learning Objectives
By the end of this chapter, you will be able to:- Define Continuous Integration (CI) and Continuous Deployment (CD).
- Understand the role of automated testing as the "Gatekeeper" of the pipeline.
- Identify popular CI/CD tools (Jenkins, GitHub Actions, GitLab CI).
- Design a basic automated deployment pipeline.
- Understand the concept of "Shift-Left" testing in DevOps.
3. Continuous Integration (CI)
Continuous Integration means developers merge their code into the main branch frequently (often daily).- The Problem: If two developers merge their code, they might conflict and break the app.
- The CI Solution: When Developer A pushes code, the CI Server (like GitHub Actions) wakes up. It compiles the code and automatically runs all Unit Tests and API Integration Tests.
- The Gatekeeper: If *one* test fails, the CI server turns Red. It blocks the merge. The broken code is rejected and never reaches the main codebase.
4. Continuous Deployment (CD)
Continuous Deployment is the next step. If the code passes CI, it is automatically deployed to the users.- The Pipeline: The code passes Unit Tests -> It is deployed to a Staging Server -> The CI server triggers the slow Selenium UI Tests -> They pass -> The code is automatically pushed to the live Production Server.
- The Requirement: CD is only possible if you have 100% trust in your automated test suite. If your tests are flaky, CD will push broken code to your users.
5. Tools of the Trade
QA Automation Engineers must know how to integrate their scripts into these tools:- Jenkins: The industry standard, open-source CI/CD automation server. Highly customizable but requires significant maintenance.
- GitHub Actions: Cloud-native CI/CD built directly into GitHub. Very popular for modern projects. Uses YAML files to define the pipeline.
- GitLab CI / CircleCI: Other popular cloud-based pipeline runners.
6. Code and Automation Examples
Example: A Simple GitHub Actions Pipeline (.yml)
yaml
7. Visual Learning: The CI/CD Pipeline Workflow
txt
8. Best Practices
- Fail Fast in the Pipeline: Organize your pipeline to run the fastest tests first. Run the 10-second Unit tests immediately. Do not run the 30-minute Selenium tests until the Unit tests pass. This gives developers immediate feedback if they broke something fundamental.
9. Common Mistakes
- Ignoring Broken Pipelines: A developer pushes code, the pipeline fails, but the team ignores it because "it's just a flaky UI test." This destroys the culture of CI/CD. A broken pipeline is a massive emergency. The team must stop all other work to fix the pipeline or fix the test.
10. Mini Project: Map a Deployment Validation Strategy
Scenario: Your team wants to implement Continuous Deployment for a Web App. Your Pipeline Map:- 1. Developer pushes code to GitHub.
- 2. GitHub Actions runs Code Linter (Formatting check).
- 3. GitHub Actions runs PHPUnit tests (Unit tests).
- 4. Code is auto-deployed to an AWS Staging Server.
- 5. Jenkins triggers Postman Newman (API Integration tests).
- 6. Jenkins triggers Playwright (UI Browser tests).
- 7. If all green, deploy to AWS Production.
11. Practice Exercises
- 1. Define the difference between Continuous Integration (CI) and Continuous Deployment (CD).
- 2. Why is a robust, non-flaky automated test suite an absolute prerequisite for Continuous Deployment?
12. MCQs with Answers
Question 1
In a CI/CD workflow, what happens if a developer pushes code to the repository and the automated Unit Tests fail on the CI server?
Question 2
Which tool is widely used as a CI/CD server to automate the execution of test suites?
13. Interview Questions
- Q: Explain the concept of the Pipeline "Gatekeeper." How do automated tests protect the main branch from regressions?
- Q: Your team's CI pipeline takes 2 hours to run because it executes massive, slow UI tests. Developers are complaining. How would you reorganize the pipeline phases to provide "Fail Fast" feedback?
-
Q: Explain what a
.ymlfile is in the context of GitHub Actions or GitLab CI.