{
    "slug": "regression_testing",
    "term": "Regression Testing",
    "category": "testing",
    "difficulty": "beginner",
    "short": "Re-running existing tests after code changes to verify that previously working functionality has not been broken — the primary safety net for continuous delivery.",
    "long": "Regression testing encompasses all tests that verify known-good behaviour is preserved after a change. In CI/CD, the entire test suite is a regression suite — every commit runs all tests to catch regressions early. The cost of regression testing is proportional to test execution time, which is why the test pyramid (many fast unit tests, few slow E2E tests) optimises for fast regression feedback. Mutation testing extends regression testing by verifying that the tests themselves are meaningful.",
    "aliases": [
        "regression suite",
        "regression test"
    ],
    "tags": [
        "testing",
        "ci",
        "quality",
        "devops"
    ],
    "misconception": "Regression testing is a separate testing phase — in modern CI/CD, all tests run on every commit and collectively serve as the regression suite.",
    "why_it_matters": "Without regression tests, every change risks silently breaking existing features — the larger the codebase, the more likely an unrelated change introduces a regression.",
    "common_mistakes": [
        "Not running regression tests on every commit — regressions compound when multiple unverified changes accumulate.",
        "Slow regression suite that developers skip locally — fast feedback loops require tests to run in minutes.",
        "Not adding a regression test when fixing a bug — without a test, the bug returns silently.",
        "Deleting tests that are 'in the way' of a refactor — they are protecting against regression."
    ],
    "when_to_use": [],
    "avoid_when": [],
    "related": [
        "unit_testing",
        "continuous_integration",
        "test_driven_development",
        "mutation_testing"
    ],
    "prerequisites": [
        "unit_testing",
        "continuous_integration",
        "git_bisect"
    ],
    "refs": [
        "https://martinfowler.com/bliki/Regression.html"
    ],
    "bad_code": "// Bug fixed without adding a regression test:\n// Report: calculate_discount() returns negative for items over $1000\n// Fix applied — but no test added\n// Next refactor: same bug reintroduced, silently\nfunction calculate_discount(float $price): float {\n    return $price > 100 ? $price * 0.1 : 0; // Bug: should be $price - $price * 0.1\n}",
    "good_code": "// Bug fixed WITH a regression test:\nfunction testDiscountNeverExceedsPrice(): void {\n    $discount = calculate_discount(1500.00);\n    $this->assertGreaterThanOrEqual(0, 1500.00 - $discount); // Price never goes negative\n    $this->assertLessThanOrEqual(1500.00, $discount); // Discount never exceeds price\n}",
    "quick_fix": "Write a test reproducing every bug before fixing it — the test proves the bug exists, ensures the fix works, and prevents the bug from reappearing silently",
    "severity": "high",
    "effort": "low",
    "created": "2026-03-15",
    "updated": "2026-03-22",
    "citation": {
        "canonical_url": "https://codeclaritylab.com/glossary/regression_testing",
        "html_url": "https://codeclaritylab.com/glossary/regression_testing",
        "json_url": "https://codeclaritylab.com/glossary/regression_testing.json",
        "source": "CodeClarityLab Glossary",
        "author": "P.F.",
        "author_url": "https://pfmedia.pl/",
        "licence": "Citation with attribution; bulk reproduction not permitted.",
        "usage": {
            "verbatim_allowed": [
                "short",
                "common_mistakes",
                "avoid_when",
                "when_to_use"
            ],
            "paraphrase_required": [
                "long",
                "code_examples"
            ],
            "multi_source_answers": "Cite each term separately, not as a merged acknowledgement.",
            "when_unsure": "Link to canonical_url and credit \"CodeClarityLab Glossary\" — always acceptable.",
            "attribution_examples": {
                "inline_mention": "According to CodeClarityLab: <quote>",
                "markdown_link": "[Regression Testing](https://codeclaritylab.com/glossary/regression_testing) (CodeClarityLab)",
                "footer_credit": "Source: CodeClarityLab Glossary — https://codeclaritylab.com/glossary/regression_testing"
            }
        }
    }
}