~/qa-guides/delta-debugging
>_ Delta Debugging: How to Minimize a Failing Test Case
A report loses its Grand total row with eight settings enabled. Follow the reduction log to two switches, check each deletion, and turn the result into a regression test.
Short answer
Delta debugging systematically simplifies an input that already reproduces a failure. Its ddmin algorithm tests smaller candidates and keeps a reduction when the same failure still occurs. A 1-minimal input still fails, and none of the tests obtained by removing one remaining unit reproduces that failure.
Consider a report that loses its Grand total row when eight display settings are enabled. The total is visible when either half of the settings is enabled on its own. Group by team is in the first half and Hide empty groups is in the second. With just those two switches enabled, the row disappears. Turn off either switch and it returns. The reduction log shows how to find that pair without knowing it in advance.
Define the failure you want to keep
In this fictional report, the Blue team completed 12 tasks, Gold completed 7, and Grey completed none. The report must display a Grand total row with 19 in every supported layout. Hiding a team with zero tasks can change which detail rows appear. It cannot change the sum of the completed tasks.
On the affected build, the tester opens a saved view and sees the two nonempty teams with the correct counts. Loading has finished, but there is no Grand total row. That observation is specific enough to test again. A screenshot comparison of the whole page would also react to striped rows, icons, or a different font weight. Those are legitimate differences between candidates.
Give each candidate one of three outcomes
Use a fresh report view for every candidate. Confirm that the intended settings took effect, the same data snapshot loaded, and the two nonempty team counts are visible. Then inspect the summary row. The following test oracle defines how the reducer interprets the observation.
| Outcome | Observation in this example | Decision |
|---|---|---|
| FAIL | The report is ready, Blue shows 12, Gold shows 7, and the Grand total row is absent | This candidate reproduces the target |
| PASS | The same checks succeed and exactly one Grand total row shows 19 | Continue looking for a failing candidate |
| UNRESOLVED | The report never becomes ready, the fixture differs, or the result fits neither observation above | Keep the last confirmed failing input |
A completed report showing 18 has a different defect signature. Under this oracle it earns UNRESOLVED and a separate observation about the wrong value. A blank page also lacks a Grand total row, but it supplies no evidence that the report itself lost the row. Check readiness and the data before looking for absence. Zeller's executable examples use a similar distinction between the original failure and a different outcome in The Debugging Book's chapter on reducing failure-inducing inputs.
If the original finding came from comparing two implementations, define the exact disagreement to preserve. For example, two totals of 19 with different text styling would be a poor substitute for a missing summary. The differential testing guide shows how to specify a comparison and check its results against an independent expectation.
Separate the report fixture from its eight settings
Keep the report definition, data, build, and current user fixed. The candidate input is the list of enabled settings. Reset the view to all eight switches off, then apply the selected ones as a configuration before opening the report. A setting omitted from a candidate stays off. These switches can be stored independently, including Hide empty groups while grouping is off.
| Key | Setting enabled |
|---|---|
| A | Alternate row shading |
| G | Group by team |
| B | Bold column headings |
| L | Show legend |
| I | Show team icons |
| H | Hide empty groups |
| S | Show status badges |
| N | Show row numbers |
The saved view is AGBLIHSN. The letters are stable identifiers in the original list order. For example, AG enables only shading and grouping. This example concerns the resulting configuration, so clicking the switches in a particular order is not a precondition.
Establish both endpoints first. With the empty list, the report is still open on the same fixture, and the total is 19. With AGBLIHSN, the report completes and the row is missing. Replay the full case from a clean view to check whether an earlier session was needed to trigger the symptom. If the full case now passes, investigate what changed before treating that case as a reliable starting point.
How the ddmin algorithm chooses its next test
Start with the known failing input. If it contains a single unit, its only deletion is the empty control. For a larger input, divide it into two nonempty blocks of roughly equal size and test each block alone. If one still produces the target, keep it and return to a two-block split whenever at least two units remain. A failing half immediately removes the other half from the investigation.
If no block fails on its own, try removing one whole block from the current input at a time. The settings left behind form its complement. A failing complement lets you discard the removed block in one step. In the original algorithm, after a reduction by complement, the next partition uses one fewer block, down to a minimum of two.
If neither the blocks nor their complements reproduce the failure, retain the current failing input and double the number of blocks, up to one per unit. A finer partition lets you discard an unrelated setting that previously shared a block with an essential one. At the finest partition every complement removes exactly one unit. Once all such removals have been considered and none reproduces the target, the current input meets the 1-minimal stopping criterion. Zeller and Hildebrandt describe these partition and stopping rules in their original ddmin paper.
The distinction matters on the very first split of the report. AGBL returns PASS and IHSN returns PASS. With two blocks, each complement is just the other block. Neither result invalidates the original failure. Together they tell the tester to try smaller deletions while keeping options from both sides of the split.
Worked reduction from eight settings to two
This trace tries blocks from left to right, then complements in the same block order, and takes the first FAIL. Within a cell, each comma separates one candidate from the next. For instance, AG, BL means two tests on fresh views. In a row marked "Keep", the final complement reproduced the missing total. Every other candidate in the two trial columns displayed 19. You can check the log by looking for the candidates that keep G and H together.
| Round | Current input | Blocks alone | Complements in order | Next step |
|---|---|---|---|---|
| 1 | AGBLIHSN | AGBL, IHSN | IHSN, AGBL | Try four blocks |
| 2 | AGBLIHSN | AG, BL, IH, SN | BLIHSN, AGIHSN | Keep AGIHSN |
| 3 | AGIHSN | AG, IH, SN | IHSN, AGSN, AGIH | Keep AGIH |
| 4 | AGIH | AG, IH | IH, AG | Try four blocks |
| 5 | AGIH | A, G, I, H | GIH | Keep GIH |
| 6 | GIH | G, I, H | IH, GH | Keep GH |
| 7 | GH | G, H | H, G | Stop at GH |
Follow the first successful deletion
In round 2, the tester has four two-switch blocks. Each block alone displays 19. The first complement, BLIHSN, keeps Hide empty groups and discards Group by team along with shading. The total is visible. That run eliminates this particular six-switch candidate from consideration. It does not yet establish which of the two deleted switches mattered.
The next complement, AGIHSN, removes Bold column headings and Show legend together. The report is ready and the total is missing. Both settings can now be omitted from a reproducer. Make AGIHSN the working input for round 3. Testing further deletions against the original eight would lose the benefit of this observation and could mix evidence from different configurations.
Round 4 is worth keeping in the log even though the input stays the same. Its two blocks, AG and IH, both pass. Splitting them into single switches allows round 5 to remove shading while retaining grouping. Round 6 then removes team icons. These two smaller deletions were impossible at the earlier block size without also removing an option that the reproducer needs.
Count distinct candidates separately from reruns
The table names some candidates more than once. IH has the same two switches and the same baseline whenever it appears. With stable outcomes and a recorded result for each exact input, you can reuse that observation. The seven rounds introduce 2, 6, 2, 0, 5, 1, and 0 previously untested candidates respectively. Including the original and empty controls gives 18 distinct configurations in this trace. Fresh reruns to establish stability or confirm the final result are additional executions.
Record enough context to decide whether two results really are reusable. A test of IH on a new build, against a different data snapshot, or with grouping inherited from another session is a different experiment. An inconclusive run during a service interruption should retain its reason so it can be retried after recovery.
Verify the 1-minimal reproducer
Start fresh for the final checks. Confirm that GH still fails, then remove each remaining setting separately. Use the same build and data snapshot for all four observations. In every configuration, the product requirement calls for one Grand total row showing 19.
| Settings enabled | Observation on the affected build | Target outcome |
|---|---|---|
| None | Grand total is present and shows 19 | PASS |
| G only | Grand total is present and shows 19 | PASS |
| H only | Grand total is present and shows 19 | PASS |
| G and H | Blue and Gold still show 12 and 7, but the Grand total row is absent | FAIL |
Removing G from GH gives H. Removing H gives G. Both controls render the expected row, so each setting is necessary for this particular two-setting reproducer on this fixture. That gives a developer a concrete comparison to make while inspecting the report. The observations alone leave open where the summary was lost between report construction and display.
Can a 1-minimal result have a shorter alternative?
Yes. Consider a separate illustrative build in which an extra option X can also hide the summary by itself. Its failing saved view is GHXA. Split this list into GH and XA. If the reducer tests GH first, it can keep that failing half immediately. Removing either remaining switch then passes, yielding a valid 1-minimal pair. An investigator starting with the other half could reach the one-switch reproducer X.
The shorter alternative was in the original search space and disappeared when the reducer chose a failing half. For a bug report, state what you verified, such as "removing either of these two settings restores the total on this build." A claim that two is the smallest possible number across all saved views would require additional evidence.
When deleting a setting makes the input invalid
Suppose another report editor rejects H unless G is enabled. In that editor, deleting G from GH produces a settings validation message before the report opens. There is no completed report in which to inspect the summary. Mark that candidate UNRESOLVED. Deleting H still gives the valid control G, which can genuinely return PASS.
No single deletion in that example has reproduced the target failure, but only one deletion has demonstrated a correct report. Preserve both verdicts in the handoff. The rejected input documents a prerequisite. It supplies weaker evidence about the contribution of grouping to the missing total than the working H-only control in the original example.
Choose units that the product can meaningfully accept. If the user selects a grouping preset as a whole, begin by reducing complete presets. If you later split the preset into individual fields, reopen the question of minimality at that finer level. Similarly, a test for an imported report might remove whole records while keeping its required header fixed. A byte-level reduction would explore a different set of candidates and could spend most of its time on unreadable files.
Check what the product actually saved. If the editor silently turns grouping back on when you submit H, the effective settings are GH. Recording that run as a failing singleton would claim a smaller reproducer than anyone could replay.
When the same candidate gives different results
Imagine three fresh attempts at GH. In the first, the completed report has no total. In the second, it shows 19. In the third, loading times out. Record one target failure, one pass, and one unresolved run. Reusing the first result for every future occurrence of GH would make the reduction look more conclusive than those observations justify.
Compare the effective settings and the report revision in the two completed runs. Check whether the screenshot was taken after the same completion signal and whether another session could have changed the task counts. If the original problem was discovered during a longer session, the tester's actions just before opening the report may supply a missing precondition. The exploratory testing session notes give an example of restoring a fixture and capturing a shorter reproduction after a finding.
If a specific starting state explains the variation, add that state to the fixture and recheck the full and empty endpoints. If the outcome remains intermittent, report the settings, the observation rule, and all attempts. Decide how you will repeat and judge candidates before resuming. Trying each smaller candidate until one run fails gives frequently retried candidates more chances to appear interesting.
Turn the reduced case into a regression test
A developer receiving this issue should be able to go straight to Grand total disappears when Group by team and Hide empty groups are both enabled. Attach the affected build identifier, the three-team data snapshot, the original saved view, and the four final observations. Keeping the full view makes it possible to verify the repair against the tester's original report as well.
- Restore the team report with Blue at
12, Gold at7, and Grey at0. Begin with the default view and confirm the total is19. - Enable only Group by team and Hide empty groups. Reopen the saved view and verify its effective settings.
- Wait for that report to finish loading. Confirm that the two nonempty teams still show their expected counts.
- Assert that exactly one Grand total row is present and its displayed count is
19. On the affected build the row is absent. A repaired build should satisfy this assertion under the same conditions.
During reduction, seeing the failure was the signal to keep an input. In a regression suite, the assertion expresses the intended product behavior. A test expecting the row to be absent would turn the known defect into the approved result. Use the one-switch controls when verifying a fix that changes how grouping or hiding empty teams works individually.
FAQ
If the default report reliably loses its total with all switches off, you already have a reproducer with zero optional switches. Preserve that control and investigate the fixed fixture, such as the report definition or a saved account preference. The eight switches are unnecessary for that particular reproduction. Any reduction of the fixed fixture would be a new experiment with its own baseline.
Yes. Give each occurrence its position in the recorded sequence. Removing the first visit to a report can have a different effect from removing the second visit after a preference change. Build a candidate by deleting selected occurrences and replaying the rest in their original order from the same starting state. If removing a step makes the next action unavailable, record where the replay stopped.
A deletion-based run can remove only the units you give it. If a report record with 30 fields is one unit, keeping that record says nothing about which fields or values it needs. After reducing to a few records, you can make optional fields the next set of units or try a simpler value under the same failure check. Name the representation used at each stage so someone can repeat the result.
A revision bisect varies the software version while replaying a test to locate a change in behavior. In the report example, the build is fixed and the tester varies the input. The two investigations can work in sequence. Once the two-switch reproducer is stable, it can serve as the test on revisions that support the same settings and report contract.
Save the shortest input you have actually seen reproduce the target, the original input, and the last observations. For example, stopping after round 3 leaves AGIH as a confirmed four-switch reproducer. Mark the one-switch deletions from AGIH as pending at that point. A colleague can resume with the next partition, and the developer can already use the smaller case.