Cover of Refactoring by Martin Fowler, Kent Beck - Business and Economics Book

From "Refactoring"

Author: Martin Fowler, Kent Beck
Publisher: Addison-Wesley Professional
Year: 1999
Category: Computers

🎧 Free Preview Complete

You've listened to your free 10-minute preview.
Sign up free to continue listening to the full summary.

🎧 Listen to Summary

Free 10-min Preview
0:00
Speed:
10:00 free remaining
Chapter 4: Building Tests
Key Insight 1 from this chapter

The Transformative Impact of Automated Self-Testing

Key Insight

Writing tests is often counterintuitive for programmers, yet it significantly increases effectiveness. A major part of programming time is spent debugging, with engineers often experiencing hours or even days trying to locate a single bug, while fixing it is typically quick. Self-testing code, however, drastically reduces this debugging burden by automatically verifying code behavior.

The shift to self-testing began with the concept that 'classes should contain their own tests'. Initially, tests involved manual console output checks, which were tedious. Automating this process by embedding expected outputs directly into the test code and having the computer perform comparisons allows tests to simply report 'OK' if all is well. This automation made running tests as easy as compiling code.

Running automated tests frequently, ideally every time code is compiled or every few minutes for active development, transforms productivity. Bugs introduced are immediately caught by existing tests, pinpointing the issue to the small amount of code just written. This drastically reduces bug-finding time from hours to mere minutes. A robust suite of tests is thus a powerful bug detector, essential for proper refactoring, as it spots inevitable mistakes even when using automated refactoring tools.

📚 Continue Your Learning Journey — No Payment Required

Access the complete Refactoring summary with audio narration, key takeaways, and actionable insights from Martin Fowler, Kent Beck.