You are previewing Growing Object-Oriented Software, Guided by Tests.

Growing Object-Oriented Software, Guided by Tests

Cover of Growing Object-Oriented Software, Guided by Tests by Steve Freeman... Published by Addison-Wesley Professional
O'Reilly logo

Chapter 14. The Sniper Wins the Auction

In which we add another feature to our Sniper and let it win an auction. We introduce the concept of state to the Sniper which we test by listening to its callbacks. We find that even this early, one of our refactorings has paid off.

First, a Failing Test

We have a Sniper that can respond to price changes by bidding more, but it doesn’t yet know when it’s successful. Our next feature on the to-do list is to win an auction. This involves an extra state transition, as you can see in Figure 14.1:

Figure 14.1 A sniper bids, then wins

image

To represent this, we add an end-to-end test based on sniperMakesAHigherBidButLoses() ...

The best content for your career. Discover unlimited learning on demand for around $1/day.