March 2015
Intermediate to advanced
236 pages
5h 26m
English
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. And though as good coding citizens we should always close streams, doing so is also a distraction.
Move these bits of clutter to @Before and @After methods. To allow both tests to take advantage of the stream.close() in the @After method, change the second test to reference the stream field instead of the local variable named inputStream.
We also ponder the line that reads:
| | assertFalse(search.errored()); |
That assertion isn’t an irrelevant detail; it’s a valid assertion. We might consider that it’s a second postcondition of running a search, but it hints at something else: ...
Read now
Unlock full access