Automated Testing with CI/CD — Your First Practical Pipeline

👩💻 Aspiring DevOps & Cloud Engineer | Learning in Public | Automation Enthusiast Hi! I’m Vaishnavi Landge, documenting my journey into DevOps, Cloud, CI/CD, and automation. I believe in learning by doing — this blog is my daily space to simplify concepts, share projects, and grow step by step. 🚀 Let’s build, automate, and deploy — together!
In the previous blog, we learned what CI/CD is and even created a simple workflow that printed a message.
Now we’ll take a very important next step: running automated tests through CI.
This blog is completely hands-on and written in the simplest terms, even if you have never written tests before.
🔹 Why Automated Testing Matters in CI/CD
When you keep updating your project, sometimes you may accidentally break something that was already working.
Automated testing helps by:
✔ Running your tests automatically
✔ Catching issues early
✔ Making sure only stable code goes into the main branch
Think of automated testing as a gatekeeper that checks the quality of your code every time you push changes.
🔹 What You Will Learn
By the end of this blog, you will understand:
What automated testing means
How CI pipelines run tests
A tiny example using Python
How to write a GitHub Actions workflow to execute these tests
🔹 Step 1: Create a Simple Program
Let’s start with a small file named calculator.py:
def add(a, b):
return a + b
This function simply adds two numbers.
That’s enough for our demonstration.
🔹 Step 2: Write a Test Case
Create another file called test_calculator.py:
from calculator import add
def test_add():
assert add(2, 3) == 5
What this test does:
It calls
add(2, 3)Checks whether the result is 5
If yes → test passes
If not → test fails
This is exactly how real applications detect bugs early.
🔹 Step 3: Create the CI Pipeline
Inside your project, create this folder:
.github/workflows/
Now create a file inside it named test.yml:
name: Run Automated Tests
on:
push:
branches: ["main"]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: "3.9"
- name: Install pytest
run: pip install pytest
- name: Run tests
run: pytest
This file is your CI automation script.
🔹 What Happens When You Push Code?
GitHub Actions will automatically:
1️⃣ Spin up a fresh Ubuntu machine
2️⃣ Download your project
3️⃣ Install Python
4️⃣ Install pytest (the testing tool)
5️⃣ Run all test files
If all tests pass, you will see:
If a test fails, you’ll see something like this :
1 passed in 0.02s
FAILED test_calculator.py::test_add
This instant feedback helps you fix issues before they reach production.
🔹 Why This Simple Example Is Powerful
Even though the example is tiny, it teaches the real CI pattern used everywhere:
Checkout the code
Set up the environment
Install dependencies
Run automated tasks
This is the foundation of pipelines used for:
✔Node.js
✔ Python
✔ Java
✔ Docker
✔ Kubernetes
✔ AWS deployments
Once you understand this flow, building real DevOps pipelines becomes easier.
🔹 Popular Testing Tools Used in CI/CD
In real DevOps pipelines, automated testing is not limited to unit tests. Different tools are used based on what needs to be tested — code quality, security, performance, or functionality.
Here are some commonly used tools:
✅ 1. Pytest (Python Testing)
Used for unit testing.
Simple syntax.
Easy to integrate with GitHub Actions.
✅ 2. JUnit / TestNG (Java Testing)
Industry-standard for Java applications.
Often used with Jenkins pipelines.
✅ 3. Jest / Mocha (JavaScript Testing)
Used for Node.js, React, and frontend apps.
Fast and powerful.
🔹 Code Quality & Static Analysis Tools
These tools don’t “run the program” — instead, they scan your code to detect bugs, vulnerabilities, and bad practices.
🟦 SonarQube
Popular code-quality and security scanning tool.
Detects:
Bugs
Code smells
Security vulnerabilities
Works with 20+ languages.
Integrates with GitHub, Jenkins, GitLab, Azure DevOps.
🟦 SonarCloud
- Cloud version of SonarQube.
🟦 ESLint
Code linting for JavaScript/TypeScript.
Ensures consistent coding style.
🟦 Pylint / Flake8
- Python code quality tools.
🔹 Security Testing Tools (DevSecOps)
Security is critical — many CI/CD pipelines include security scans.
🔒 Snyk
Detects vulnerabilities in dependencies.
Works well with GitHub pipelines.
🔒 Trivy
Container image security scanning.
Checks for CVEs inside Docker images.
🔒 OWASP ZAP
- Web application security testing.
🔹 Performance Testing Tools
These tools check if the app performs well under load.
🚀 JMeter
Load testing and performance testing.
Often integrated with Jenkins.
🚀 Locust
Python-based load testing tool.
🔹 Summary
In this blog, you learned:
The role of automated testing in CI/CD
How GitHub Actions prepares a server for your pipeline
How to write a workflow that runs tests automatically
How CI verifies your code on every push
This is your first real CI pipeline, and it sets the stage for advanced automation.
🔹 Coming Up Next
Next Blog → Learn Docker basics before creating a CI pipeline that automatically builds Docker images.


