Regression Testing
What is Regression Testing?โ
Regression testing is the process of re-running existing test suites after code changes to verify that previously working functionality has not been broken โ intentionally or accidentally.
Every code change โ no matter how small โ is a potential regression risk. A 1-line config change once took down a production payment service for 45 minutes.
Why Regression Testing Mattersโ
| Scenario Without Regression Testing | Consequence |
|---|---|
| Developer fixes bug A, inadvertently breaks feature B | Feature B fails silently in production |
| Dependency upgrade changes serialisation behaviour | API responses differ; consumers break |
| Database migration drops a column still used in code | NullPointerException in production |
| New service added to the call chain changes latency | SLAs breached without warning |
Types of Regression Testingโ
Full Regressionโ
Run the complete test suite across all modules. Done before every major release.
- Slowest, most comprehensive
- Catches the broadest range of issues
- May take 30โ90 minutes in CI
Targeted/Partial Regressionโ
Run only tests related to the changed area. Used for patch releases and hotfixes.
- Faster feedback loop
- Higher risk of missing indirect regressions
- Use test impact analysis tools to determine scope
Automated Regression (Recommended)โ
The regression suite is automated and runs in CI/CD on every merge to develop or release/**:
Developer merges PR
โ
CI triggers regression suite
โ
Unit tests โ Integration tests โ API tests โ Smoke E2E
โ
Results reported to PR / Slack / Jira
โ
Gate: All passed? โ Allow merge to release branch
Any failed? โ Block, notify, assign
Regression Suite Designโ
What to Includeโ
- All existing unit tests
- All integration tests
- API contract tests (Spring Cloud Contract / Pact)
- Critical user journey smoke tests
- Previously failing tests that were fixed (prevent re-occurrence)
What NOT to Includeโ
- Exploratory tests (manual only)
- Performance tests (separate pipeline)
- Tests known to be flaky โ fix or quarantine them
Regression in the Java/Spring Ecosystemโ
Spring Cloud Contract โ Contract-Based Regressionโ
Define producer-side contracts that are published as stubs for consumers:
// contracts/TransactionController/shouldReturnTransactionsForUser.groovy
Contract.make {
description "GET /api/v1/transactions returns 200 with page of transactions"
request {
method GET()
url('/api/v1/transactions') {
queryParameters {
parameter 'fromDate': '2024-01-01'
parameter 'toDate': '2024-01-31'
}
}
headers {
authorization(matching('Bearer .+'))
}
}
response {
status 200
headers {
contentType(applicationJson())
}
body([
totalElements: $(consumer(anyNumber()), producer(1)),
content: [[
id: $(consumer(anyUuid()), producer('3fa85f64-5717-4562-b3fc-2c963f66afa6')),
amount: 99.99
]]
])
}
}
These contracts auto-generate regression tests on both producer and consumer sides.
Regression Test Managementโ
Test Tagging Strategyโ
@Tag("regression")
@Tag("transactions")
@SpringBootTest
class TransactionRegressionTest {
// ...
}
Run tagged regression tests in CI:
mvn test -Dgroups="regression"
Handling Flaky Testsโ
Flaky tests destroy trust in the regression suite. Treat them as P2 defects:
- Identify flaky test (fails intermittently)
- Quarantine: add
@Disabled("JIRA-456: flaky โ intermittent race condition") - Create a Jira ticket to fix it
- Fix root cause (often timing issues, test pollution, or real race conditions)
- Re-enable and monitor
Metrics to Trackโ
| Metric | Target |
|---|---|
| Regression pass rate | โฅ 99% on every release |
| Regression execution time | < 30 minutes for full suite |
| Flaky test rate | < 1% of total test count |
| Defect escape rate | < 2% of defects reach production |
Exit Criteria for Regressionโ
- Full regression suite executed on the release candidate build
- 100% of tests passed (or failures are investigated and accepted)
- No new flaky tests introduced
- Results documented in Test Summary Report
- Tech Lead and QA Lead sign-off
Regression testing validates that existing functionality still works. New features require their own dedicated test cases before being added to the regression suite.