Test Smell: Bloated Construction
Discover how to refactor bloated constructors in your JUnit tests by introducing helper methods that simplify object instantiation. This lesson teaches you to hide complex setup details, enhancing test clarity and maintainability while ensuring tests pass reliably.
We'll cover the following...
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 ...