Test Smell: Unnecessary Test Code
Learn about exceptions in Search methods and how to prevent them.
We'll cover the following...
Expect the exceptions
The test code that comprises testSearch()
doesn’t expect any exceptions to be thrown. It contains a number of assertions against positive facts. If the test code throws an exception, a try/catch
block catches it, spews a stack trace onto System.out
, and explicitly fails the test.
In other words, exceptions are unexpected by this test method. ...