Test Smell: Irrelevant Details
Explore how to refactor unit tests by removing irrelevant details such as logging and stream closing clutter. Learn to use @Before and @After methods for setup and teardown while ensuring tests remain clear and easy to understand without hiding essential assertions.
We'll cover the following...
We'll cover the following...
Distractions
Although we want to turn off logging when tests run, the code to do so is a distraction to understanding the essence of any test. Though we should always close streams, doing so is also a distraction.
Using @After and @Before methods
To remedy this issue, let’s move the bits of clutter to @Before and ...