Skip to content
IRC-CodingIRC-Coding
TDDCICDRed Green RefactorGitHub Actions

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

Test-Driven Development and CI/CD explained: Red-Green-Refactor cycle, Continuous Integration/Delivery, tools, and exam questions.

S

schutzgeist

1 min read
TDD & CI/CD: Red-Green-Refactor Pipeline

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

  1. Unit Tests
  2. Test frameworks (JUnit/pytest)
  3. CI servers (Jenkins/GitHub Actions)
  4. Build tools
  5. Containers/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 debugging
  • Repeatable deployments

Disadvantages

  • Initial setup effort
  • Infrastructure required
  • Discipline needed

Common Exam Questions (with Quick Answers)

  1. What does Red-Green-Refactor mean? Write a test, implement minimally to pass it, then refactor.
  2. Goal of CI? Automated testing and integration.
  3. 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

  1. Build a small function using TDD.
  2. Set up a GitHub Actions pipeline for build and test.
  3. Sketch your pipeline on paper (useful for exams).
  4. Never deploy without tests.

Key Resources

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

Nächster Artikel in Software Architecture

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

Related Posts