Searching for an Understanding

We’re tasked with making some enhancements to the search capabilities of our application. We know we’ll be changing the util.Search class, but none of us is familiar with exactly what the Search class does. We turn to the tests. Well, test. We have only one test, and at first glance we roll our eyes in frustration. What in the world is this test trying to prove?

import​ java.util.*;
import​ org.junit.*;
import​ java.util.logging.*;
import​ static org.hamcrest.CoreMatchers.*;
import​ static org.junit.Assert.*;
public​ ​class​ SearchTest {
public​ ​void​ testSearch() {
try​ {
String​ pageContent ...

Get Pragmatic Unit Testing in Java 8 with JUnit now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.