What would you automate for functions and side effects while refactoring without changing behavior, and what would you leave manual?
Answer
Before automating, begin by making inputs, outputs, ownership and failure behavior explicit before choosing an implementation. Focus on functions and side effects while refactoring without changing behavior. Use small deterministic units plus integration behavior at real boundaries as the oracle. Cover normal flow, invalid inputs, exceptions, concurrency and resource cleanup. Keep data and dependencies controlled enough to reproduce failures. Release only when tests fail for one understandable reason and the code remains easy to change.
Strong answer includes
- explicit risk and test oracle for functions and side effects
- controls side effects and dependencies
- designs for deterministic tests
- measurable evidence and residual-risk statement
Practical example
Before splitting a monolithic 'processOrder' function into smaller pieces, the team recorded its side effects (emails sent, rows written, events published) for a fixed set of sample orders and turned that into an automated characterization test suite. Manually, a lead still reviewed the diff for cases the fixtures didn't cover, like a rare partial-refund path, before merging.