O'Reilly logo

Quality Code: Software Testing Principles, Practices, and Patterns by Stephen Vance

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

First Functionality

Applying the recipe from Chapter 3, I jumped immediately into the happy path. The purpose of the application is to retrieve content from URLs. The simplest happy path retrieves content from a single URL. I defined the basic retrieve() method through its test (Listing 14-1).

Listing 14-1: Defining a simple retrieve() method by using it in its test [0c2d67e]. This “fails” because the method does not exist.

@Testpublic void testRetrieve_SingleURI() {  WebRetriever sut = new WebRetriever();  String content = sut.retrieve("http://www.example.com");}

For now, in the spirit of YAGNI, the simplest implementation takes the URL and returns the retrieved content as strings, deferring the questions of command-line ...

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