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 ...

Get C# and .NET Core Test Driven Development 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.