Site Tools


swe:regression

Table of Contents

Regression

Regression is a bug introduced by a change that fixed something else or violated a hidden assumption. The feature previously worked, so something broke it.

Without protection, the same bug can be reintroduced months later by someone unaware of the original fix. The cost accumulates: each re-introduction requires re-diagnosis and re-fixing.

A regression test reproduces a known bug, fails until the bug is fixed, then passes and is kept permanently. When run in a CI/CD pipeline, these tests catch regressions immediately. The key is treating the test suite as sacred: keep it green and treat any failure as urgent, otherwise you lose signal about what actually broke.

This example shows a regression test from a real bug: users with special characters in passwords couldn't log in, now permanently guarded by a test.

# Regression test: known bug from 3 months ago
def test_login_with_special_characters():
    """
    Bug: Users with @ in password couldn't log in.
    Fixed in commit abc123, but reintroduced in commit xyz789.
    This test prevents it from happening again.
    """
    user = create_user(password="pass@word!")
    assert login(user.email, "pass@word!") == True
swe/regression.md · Last modified: by 127.0.0.1