Mhonn YbañezSRE, DevOps, AI Engineer
 Today I Learned
Read the full page

What is regression testing?

Posted
Tags
testing, fundamentals, ci-cd

A regression is something that used to work and broke after a change. Regression testing re-runs a fixed set of old tests after every change to catch that, even in features the change never touched. It fits naturally into CI/CD, but a pipeline only helps if someone wrote the tests, and the suite has to stay fast and trusted.

I recently talked with a test engineer and got curious about what their day actually looks like. One term kept coming up that I only half understood: regression testing. So I went and learned it properly.

The question I had

What is regression testing, and why does every team seem to do it?

What I found

The short version

A regression is something that used to work and no longer does, because of a recent change. The feature went backwards.

Regression testing means re-running tests for existing behavior after a change, to confirm it all still works. It is not a special kind of test. Unit, integration, and end-to-end tests can all be regression tests. The word describes why I run them: to make sure I didn't break something that was fine yesterday.

Why a change breaks things I didn't touch

Code is connected. Change something that is shared, and everything that depends on it changes too. Here is a tiny example in JavaScript. Someone edits applyDiscount so a promo banner can show whole dollars:

import assert from "node:assert/strict";

// Someone changes this so a promo banner shows whole dollars
function applyDiscount(price, percent) {
  return Math.round(price * (1 - percent / 100));
}

function checkoutTotal(items, couponPercent = 0) {
  const subtotal = items.reduce((sum, item) => sum + item.price, 0);
  return applyDiscount(subtotal, couponPercent);
}

// Written long ago, never touched, still guarding checkout
assert.equal(checkoutTotal([{ price: 10 }, { price: 5.5 }], 0), 15.5);

Checkout was never edited, but it calls applyDiscount, so a cart of 15.50 now totals 16. I ran it, and the old test fails with 16 !== 15.5. That failing test is the regression test doing its job.

Retesting is not regression testing

These two get mixed up a lot:

RetestingRegression testing
QuestionIs the bug I just fixed really fixed?Did my change break anything else?
ScopeThat one bugEverything that already worked
TestsThe failing caseA fixed, repeatable set of existing tests

Every bug becomes a test

The habit that makes it work: when a bug is found, I first write a test that reproduces it and fails. Then I fix the bug and the test passes. That test stays in the suite forever, so the same bug can't come back without someone noticing. This is how a regression suite grows over time. Every fix and every new feature adds tests that guard it from then on. It is also close to the idea in spec-driven development, where the tests are a written promise of how the system should behave.

Where it runs

  • On every pull request, automatically, in CI.
  • Before a release.
  • After upgrading a dependency, since I didn't write that code but my app depends on it.

Which tests count

LevelWhat it checksSpeed
UnitOne small piece of code in isolationVery fast
IntegrationSeveral pieces working together, like code plus a databaseMedium
End to endA whole flow like a real user, through the UI or APISlow
VisualScreenshots compared against an approved versionSlow

A healthy suite usually has many fast tests and a few slow ones.

The cost

Regression testing has a price:

  • The suite grows and gets slow. Running everything is called retest-all, and it stops being practical at some point.
  • Flaky tests. A test that sometimes fails for no real reason teaches people to ignore red results, which defeats the purpose.
  • Upkeep. When the product changes on purpose, the tests have to change too.

Teams cope in a few ways, and the details depend on the team. They run fast tests on every change and slow ones nightly. They run only the tests related to the change. They fix or delete flaky tests quickly.

Smoke, sanity, and regression

Three terms that blur together. Teams use them a bit differently, but the common meanings are:

TestThe question
SmokeDoes it even start and do the basics?
SanityAfter a small change, does that one area still look right?
RegressionDoes all the existing behavior still work?

What it can't do

It only catches breakage that some test already covers. A feature with no test can break and nobody will know. A passing regression suite means "nothing I tested got worse", not "there are no bugs".

Where my epiphany came in

My first reading of it was: it's like a standardized test of functionality. A fixed set of checks runs after every change, and features the change never touched still get tested. That held up.

Then I thought about CI/CD. Regression testing is the kind of testing that CI/CD should help with, because a pipeline can run the suite on every change without anyone remembering to. But not always. A pipeline only runs what exists, so with no regression tests it is just a fast way to ship. Some regression checks are also too slow for every commit, and some still need a person to look. CI/CD is where regression testing runs, but it doesn't create the tests or keep them healthy. This is the same reason checks around AI-made changes matter: speed without a safety net just ships breakage faster.

Takeaway

Regression testing is a safety net made of old tests, and it grows every time something breaks or ships. CI/CD is the natural place to run it, but the value comes from the tests being written, fast, and trusted.