Course contentsShow
← Software Engineering
Lesson 406 of 1,93312. Testing FundamentalsFree lesson

Balancing Testing Investment

Aim for sufficient testing to catch critical bugs without over-investing in low-value or brittle tests.

Balancing Testing Investment

You'll learn how to decide where and how much to test without wasting effort or leaving critical gaps.

The Testing Investment Problem

Writing tests takes time and effort. Too few tests mean bugs slip through to production, causing expensive failures and user frustration. Too many tests—especially fragile ones that break whenever code changes—slow down development without meaningful protection. The key is investing wisely in tests that provide the best return: catching important bugs while staying maintainable.

Think of testing like insurance. You wouldn't insure your paperclips but you'd definitely insure your house. Similarly, critical authentication logic deserves thorough testing, while a simple display formatter might need only basic coverage.

Where to Focus Your Testing Effort

High-value targets include business logic, security-critical code, payment processing, data integrity, and complex algorithms. These areas have the highest cost when they fail.

Lower-value targets include trivial getters/setters, simple formatting functions, or UI tweaks that change frequently. Brittle tests here create maintenance burden without catching meaningful bugs.

The Trade-off Triangle

Every test has three dimensions to consider:

  • Cost to write and maintain (time, complexity)
  • Bug-catching power (what failures it prevents)
  • Fragility (how often it breaks for non-bug reasons)

Ideal tests have low cost, high bug-catching power, and low fragility. Avoid tests that score poorly on all three.

Practical Balancing

As covered in "What to Test: Risk-Based Testing" and "When Not to Test: Diminishing Returns," prioritize by risk and impact. Start with core functionality. Add tests when bugs occur in an area. Reduce or remove tests that constantly break without finding real issues.

Key Takeaway: Invest testing effort where failures hurt most—protect critical paths thoroughly while accepting lighter coverage on low-risk code to maintain development velocity and avoid test maintenance burden.