TDD & CI/CD
This article provides a glossary entry for TDD and CI/CD, including exam questions, core components, and key topics.
In a Nutshell
TDD: Tests are written before code (Red–Green–Refactor). CI/CD: automated integration and delivery via pipelines.
Technical Overview
TDD follows this cycle:
- Red: Write a test that fails
- Green: Write minimal code to pass the test
- Refactor: Improve code without changing functionality
CI/CD:
- CI: Build and test run automatically after every commit
- CD: Automated delivery (Delivery to staging, Deployment to production)
Exam Essentials
- TDD = test first
- Red-Green-Refactor cycle
- CI = automated build and testing
- CD = automated delivery (IHK-relevant)
- TDD increases test coverage
- CI/CD reduces manual errors (security benefit)
- Faster releases (business value)
- Pipeline must be documented
Core Components
- Unit Tests
- Test frameworks (JUnit/pytest)
- CI servers (Jenkins/GitHub Actions)
- Build tools
- Containers/Deployment
- Pipeline scripts
- Rollback strategies
- Staging environments
- Code quality tools
Practical Example (pytest)
def add(a, b):
return a + b
def test_add():
assert add(2, 3) == 5
Advantages and Disadvantages
Advantages
- Higher code quality
- Automated QA
- Faster debugging
- Repeatable deployments
Disadvantages
- Initial setup effort
- Infrastructure required
- Discipline needed
Common Exam Questions (with Quick Answers)
- What does Red-Green-Refactor mean? Write a test, implement minimally to pass it, then refactor.
- Goal of CI? Automated testing and integration.
- Delivery vs Deployment? Delivery reaches staging, Deployment reaches production.
Open-Ended Response
TDD forces you to think about requirements and interfaces early. In a DevOps context, CI/CD is now standard practice and demonstrates professionalism in real projects.
Learning Strategy
- Build a small function using TDD.
- Set up a GitHub Actions pipeline for build and test.
- Sketch your pipeline on paper (useful for exams).
- Never deploy without tests.



