Monster Constructor
To test a method, you have to instantiate or construct the class containing the method. The most common mistake developers make is to create what I call Monster Constructor, which is simply a constructor that does too much work or real work, such as performing I/O operations, database calls, static initialization, reading some large files, or establishing communication with external services.
When you have a class designed with a constructor that initializes or instantiates objects other than value objects (list, array, and dictionary), the class technically has a nonflexible structure. This is a bad class design because the class automatically becomes strongly tied to the classes it is instantiating, making unit testing ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access