Skip to content
IRC-Coding IRC-Coding
TDD CI CD Red Green Refactor GitHub Actions

TDD & CI/CD Explained: Red-Green-Refactor & Pipeline

Master Test-Driven Development and CI/CD: Red-Green-Refactor cycle, continuous integration, delivery, deployment, tools, and exam questions.

S

schutzgeist

2 min read

TDD & CI/CD

This article is a definition of terms for TDD and CI/CD – including exam questions, core components, and tags.

In a Nutshell

TDD: Tests are written before code (Red–Green–Refactor). CI/CD: automated integration and delivery via pipelines.

Compact Technical Description

TDD follows the cycle:

  • Red: write a test that fails
  • Green: minimal code to make the test pass
  • Refactor: improve without changing functionality

CI/CD:

  • CI: build + tests after every commit
  • CD: automated delivery (Delivery to staging, Deployment to production)

Exam-Relevant Key Points

  • TDD = test first
  • Red-Green-Refactor
  • CI = automated building/testing
  • CD = automated delivery (IHK-relevant)
  • TDD increases test coverage
  • CI/CD reduces manual errors (security)
  • Faster releases (cost-effectiveness)
  • Pipeline must be documented

Core Components

  1. Unit Tests
  2. Test frameworks (JUnit/pytest)
  3. CI servers (Jenkins/GitHub Actions)
  4. Build Tools
  5. Container/Deployment
  6. Pipeline scripts
  7. Rollback strategies
  8. Staging environments
  9. 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 error detection
  • Repeatable deployments

Disadvantages

  • Initial overhead
  • Infrastructure required
  • Discipline required

Typical Exam Questions (with Short Answer)

  1. What does Red-Green-Refactor mean? Write a test, implement minimally, then refactor.
  2. Goal of CI? Automated testing and integration.
  3. Delivery vs Deployment? Delivery to staging, Deployment to production.

Free Response

TDD forces early thinking about requirements and interfaces. CI/CD is standard in the DevOps context and demonstrates professionalism in projects.

Learning Strategy

  1. Develop a small function using TDD.
  2. Set up a GitHub Actions pipeline for build/test.
  3. Sketch the pipeline on paper (for exams).
  4. No deployment without tests.

Most Important Sources

  1. https://martinfowler.com/bliki/TestDrivenDevelopment.html
  2. https://docs.github.com/en/actions
Back to Blog
Share:

Related Posts