O'Reilly logo

Extreme Programming Installed by Chet Hendrickson, Ann Anderson, Ron Jeffries

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Testing Interconnection

Somehow we must associate a Searcher with our GUI, and verify that we display its results.

We'll give our panel two methods, getSearcher() and setSearcher(),that will associate a Searcher with the panel. This decision lets us write another test:

public void testSearcherSetup() {
    Searcher s = new Searcher() {
      public Result search(Query q) {return null;} 
    };
    SearchPanel panel = new SearchPanel();
    assert ("Searcher not set", panel.getSearcher() != s);
    panel.setSearcher(s);
    assert("Searcher now set", panel.getSearcher() == s);
  }

The compile fails, so bounce over to the SearchPanel, add the methods, run the tests again, and they fail. Implement the set/get methods, and the test passes.

The panel still can't do much, but now ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required