Chapter 5. Unit Testing the Legacy Code with Mockito

"Legacy code. The phrase strikes disgust in the hearts of programmers. It conjures images of slogging through a murky swamp of tangled undergrowth with leaches beneath and stinging flies above. It conjures odors of murk, slime, stagnancy, and offal. Although our first joy of programming may have been intense, the misery of dealing with legacy code is often sufficient to extinguish that flame."

– Michael C. Feathers, Working Effectively with Legacy Code

This chapter explores the following topics:

  • Understanding the legacy code
  • Working with testing impediments
  • Exploring PowerMock
  • Designing for testability with Mockito and PowerMock

Understanding the legacy code

The term legacy is frequently used as a slang ...

Get Mockito Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.