Skip to Content
Learning Test-Driven Development
book

Learning Test-Driven Development

by Saleem Siddiqui
October 2021
Intermediate to advanced
277 pages
5h 48m
English
O'Reilly Media, Inc.
Content preview from Learning Test-Driven Development

Chapter 12. Test Order

My journey has always been the balance between chaos and order.

Philippe Petit

In Chapter 11, we undertook a relatively significant design change by introducing the Bank entity. Both the new test we wrote and the existing tests helped us accomplish this goal.

One feature of the new Bank entity is its ability to accept and store an exchange rate between any pair of currencies. The way we designed (and tested) it—the exchange rates are stored in a hashmap and in the keys formed from the two currencies—gives us reason to believe that we already have the next feature on our list. That feature is to allow exchange rates to be modified.

One way to gain confidence that this feature works is (no prizes for guessing) to write a test to prove it. Why should we write a test when the feature is likely already there? In other words, what could a new test possibly drive, if the development has already been done?

Three answers can be provided to this question:

  1. To repeat: a new test would increase our confidence in this feature, even if no new production code is necessary.

  2. The new test would serve as executable documentation of this feature.

  3. The test may expose inadvertent interactions between existing tests, thereby prompting us to address them.

Tests are an effective way to document our code. Because we can (and should) use meaningful names for our tests, and because they lay out in detail what a feature does (as opposed to how it works), tests are an excellent ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Learning Domain-Driven Design

Learning Domain-Driven Design

Vlad Khononov
Learning Go

Learning Go

Jon Bodner
Learning React, 2nd Edition

Learning React, 2nd Edition

Alex Banks, Eve Porcello

Publisher Resources

ISBN: 9781098106461Errata Page