Reproducing Bugs
Reproducing a bug means finding the exact steps, data and conditions that make it happen every time. It turns a vague report such as "it sometimes breaks" into a scenario that you, a colleague or a test can repeat.
Gather the facts
Start with the report, then fill in what is missing. Ask for or find out:
- What did the user do, step by step, and what did they expect?
- What actually happened? Get the exact error text or a screenshot.
- When did it start? Did anything change just before: a release, a configuration change, new data?
- Who and where is affected: one user, some users, all users, one browser, one environment?
- Logs, request identifiers and timestamps that tie the report to what the system recorded. See Log Analysis.
A well-written report already contains most of this. See Defect Reporting.
Recreate the conditions
Bugs depend on context, so match it as closely as you can:
- Check out the same release or commit that the reporter used.
- Match the environment. Configuration, feature flags and environment variables can change behaviour. See Environments.
- Use a copy of the failing input, anonymised if it is personal data. See Test Data Management.
- Look at timing and state. Time zones, the current date, caching, the order of operations and parallel requests can all matter. See Dates, Times and Time Zones and Concurrency and Parallelism.
Make it small and repeatable
Once you can trigger the bug, shrink it:
- Remove steps, inputs and configuration one at a time while the bug still occurs.
- Replace real services with fixed values where possible.
- Capture the result as a script, an API call or an automated test that fails.
The smallest failing case is the best clue about the cause, and it is exactly what the fix must make pass.
When it will not reproduce
- Compare the differences between the failing and working cases: user, data, environment, version.
- Add targeted logging and wait for it to happen again.
- If it started at a known point, use
git bisectto find the commit that introduced it: mark a good and a bad commit, then repeat the test at each step Git suggests (it can also run a script for you withgit bisect run). - Say so honestly in the ticket, with what you tried. “Cannot reproduce” is information in itself.
Try it
Take a bug from your backlog, or invent one: a form that fails only when a name contains an apostrophe. Write down the minimal steps and input that trigger it, then express them as one automated test or a single command that fails. Hand the steps to a colleague and see whether they get the same result.
Common mistakes
- Fixing a bug nobody has reproduced.
- Using a different release or environment from the reporter.
- Using real personal data without anonymising it.
- Not recording what you tried when it will not reproduce.
Check yourself
- What should you ask for in a vague bug report?
- Why shrink a reproduction?
- What does git bisect need you to provide?