O'Reilly logo

Head First Software Development by Russ Miles, Dan Pilone

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

Chapter 8. Test-Driven Development: Holding your code accountable

image with no caption

Sometimes it’s all about setting expectations. Good code needs to work, everyone knows that. But how do you know your code works? Even with unit testing, there are still parts of most code that go untested. But what if testing was a fundamental part of software development? What if you did everything with testing in mind? In this chapter, you’ll take what you know about version control, CI, and automated testing and tie it all together into an environment where you can feel confident about fixing bugs, refactoring, and even reimplementing parts of your system.

Test FIRST, not last

Instead of trying to retrofit testing onto an existing project, let’s look at a project from the ground up using a new technique, test-driven development, and write your code with testing in mind right from the start.

Starbuzz Coffee has been selling gift cards for several months, but now they need a way to accept those gift cards as payment for their drinks. Starbuzz already knows how their page should look, so your job is to focus on the design and implementation of the gift card ordering system itself.

image with no caption
image with no caption

So we’re going to test FIRST...

The Starbuzz ...

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