Test Smell: Bloated Construction

Learn how to prevent bloated construction in your tests.

We'll cover the following

The constructor should only satisfy the necessary object’s preconditions. When a lot of code has to be executed to get the things instantiated, though, it becomes bloated and is called a bloated constructor.

We must pass an InputStream to a Search object through its constructor. Our test builds an InputStream in two places. The first construction requires three statements (lines 8-16):

Get hands-on with 1200+ tech skills courses.