Repair the test suite or rebuild it from scratch?
Updated:
When a test suite fails frequently and the team does not understand it, a complete rewrite can seem like the simplest solution. In practice, that may discard valid scenarios and valuable product knowledge. With unsupported dependencies, assess replacing the foundation too. A repair may provide a temporary measure that preserves necessary checks. Tests of retired processes need their continuing purpose assessed.
Why an all-or-nothing decision fails
A single suite often contains strong critical scenarios, duplicate checks, fragile infrastructure and obsolete tests side by side. One decision for the entire repository therefore tends to cause either an unnecessary rewrite or endless repairs.
Tests also preserve the team’s experience: edge cases, permissions and combinations that have caused problems before. This knowledge does not automatically survive a rewrite, especially when the original author is no longer available.
Four possible decisions
Repair
Repair is appropriate when the scenario still provides value, the tool is maintained and the problem has a local cause. The issue may be a selector, waiting logic, test data or environment configuration. After the repair, the same measurement should confirm that instability has fallen.
Redesign
The test may have the right objective while its steps are duplicated or too tightly coupled to the interface. In that case, preserve the scenario and its assertions but improve the architecture, data setup or separation of responsibilities. Redesign can proceed incrementally so the working part of the suite remains available.
Migrate
Migration makes sense when the tool, language or infrastructure no longer has a sustainable future within the team. It is not a mechanical line-by-line translation. Valid scenarios and expectations are retained while the technical foundation is rebuilt. Our test migration service covers this option.
Retire
A test can be removed if it checks a discontinued feature, exactly duplicates another check, or has no useful outcome after its purpose has been assessed. Investigate an unclear test first so a hidden business rule is not lost. Someone who knows the product should confirm the decision, and the reason should remain traceable.
How to assess the suite
First, run it in a known, reproducibly prepared environment and measure its instability. Then assess every scenario against:
- its importance to the customer or a key process,
- the validity of its expected outcome,
- the frequency and cause of failures,
- the state of the tool and its dependencies,
- maintenance effort and the skills available within the team,
- the cost of repair compared with migration.
The result does not have to be one answer. A plan may combine several categories: repair or migrate some critical tests, redesign the architecture incrementally, and retire obsolete checks.
What to watch out for
A new framework will not by itself remove unsuitable scenarios, shared data or missing ownership. If the same design mistakes are copied during migration, the new suite will develop the same problems over time. Understand the cause before making the decision. Failure counts alone are insufficient.
Look for a shared cause first
Group failures by location and cause. If several tests stop at the same sign-in step, not every scenario is necessarily faulty. Check shared setup, the account, environment and last change. An unexecuted order assertion does not establish an order defect if the test never reached that step.
Distinguish a product defect from a test defect. If the product returns an incorrect price, do not change the expectation simply to make the suite pass. For an ambiguous selector, preserve the meaning and find the intended element. Playwright documents locator uniqueness and the risk of selecting the first of several elements.
For each group, record evidence supporting the cause and open questions. Failure counts alone do not determine rewrite scope. ISTQB recommends assessing change impact and checking unchanged areas too.
A decision overview needs evidence
These rows are illustrative situations. They do not describe an audit of a particular company or provide rules for automatic rewriting:
| Situation | Possible approach | What must remain verified |
|---|---|---|
| A valid purchase journey fails at a changed identifier | Repair the locator | The same purchase and business assertions |
| The same basket setup is copied into many tests | Redesign shared setup | Individual rules and independent runs |
| An unsupported setup blocks necessary scenarios | Assess migration | Target environment, coverage and continued operation |
| Two checks verify the same rule under the same conditions | Assess retiring the duplicate | Replacement coverage includes relevant boundaries |
Similar clicks do not establish duplication. Compare roles, data, expectations and configuration. A retired screen’s test may still contain an important rule that moved elsewhere. Before deletion, decide where that rule will be verified. Choosing tests to retire safely explains the detail.
Compare costs and remaining risk
Choose matching periods and scope for repair and rewriting. For repair, include diagnosis, repeated interventions and old-foundation limits. For migration, include scenario analysis, new setup, training, parallel operation and subsequent maintenance. Line count alone is not a budget.
State estimate confidence and what still needs investigation. If half the suite’s purpose is unknown, choosing a new framework cannot turn that uncertainty into a fixed budget. Assess a representative part first and adjust the estimate using its outcome.
Compare the consequences of delay too: an unverified critical journey, blocked updates or reliance on one person. A cheaper technical change may not address the necessary risk. The decision should state what happens now and which limitation remains accepted until the next stage.
The pilot must detect incorrect behaviour too
Choose a critical journey, an ordinary journey and a case using shared setup or a more demanding dependency. Match the selection to the suite, rather than a mandatory test count. A pilot on the simplest page alone does not establish that the whole migration will work.
Verify a correct outcome and detection of the relevant known fault in a controlled environment. Playwright recommends isolated tests and assertions that wait for the expected state. A new browser context alone does not clean a shared account or server records. Prepare and restore that data too.
Compare matching conditions before and after the change. Track first attempts, retries, diagnosis time and retained assertions. Playwright Test distinguishes first-attempt success from success after retry. Check Python pytest suite configuration separately. Increasing retries alone does not establish a repair.
A suite change needs staged acceptance
Map every moved rule to its original and new check, owner and acceptance status. Until the replacement is verified, keep the gap visible. For concurrent tests that write data, separate accounts and records so the suites do not change each other’s initial state.
Before disabling the old part, verify the tests actually executed in CI, reports and result delivery. Agree on a usable rollback or alternative check. Old tests that no longer work on the current application are not automatically a fallback.
After acceptance, remove unnecessary execution and access with regard to other users. Retain the decision, coverage map and necessary historical results. The new part’s owner needs to know how it runs, why its assertions exist and what to do after the next change.
What you gain
- Valid scenarios and product knowledge are preserved.
- Spending is directed towards repairs with a clear benefit instead of a blanket rewrite.
- A risky technical foundation can be replaced incrementally.
- The team receives a clear plan for what will happen to each part of the suite.
Next step
Choose a representative part of the suite and label each test with its purpose, status and most frequent reason for failure. If you need an independent assessment, contact us. We will prepare a decision overview covering repair, redesign, migration or retirement, together with an order for the next steps.