Refactoring the classes that use static methods
In this recipe, we will refactor classes that call static methods to execute business logic instead of having their external dependencies properly defined.
Getting ready
Similar to the previous examples, our system under test is a system that generates a new identity for a given person. Each person can have a name, an age, and siblings. Please remember that the following class is very poorly designed (all the test examples are written for JUnit; please refer to Chapter 1, Getting Started with Mockito, for the TestNG configuration and Chapter 7, Verifying Behavior with Object Matchers, for the AssertJ configuration and the BDDAssertions
static imports):
public class BadlyDesignedNewPersonGenerator { ...
Get Mockito Cookbook 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.