Skip to Content
Test Driven Development: By Example
book

Test Driven Development: By Example

by Kent Beck
November 2002
Intermediate to advanced
240 pages
5h 9m
English
Addison-Wesley Professional
Content preview from Test Driven Development: By Example

Chapter 13

Make It

We can’t mark our test for $5 + $5 done until we’ve removed all of the duplication. We don’t have code duplication, but we do have data duplication—the $10 in the fake implementation:

Bank

Money reduce(Expression source, String to) {
   return Money.dollar(10);
}

is really the same as the $5 + $5 in the test:

public void testSimpleAddition() {
   Money five= Money.dollar(5);
   Expression sum= five.plus(five);
   Bank bank= new Bank();
   Money reduced= bank.reduce(sum, "USD");
   assertEquals(Money.dollar(10), reduced);
}

Before when we’ve had a fake implementation, it has been obvious how to work backward to the real implementation. ...

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.
Start your free trial

You might also like

Refactoring: Improving the Design of Existing Code

Refactoring: Improving the Design of Existing Code

Martin Fowler
Refactoring: Improving the Design of Existing Code

Refactoring: Improving the Design of Existing Code

Martin Fowler, Kent Beck, John Brant, William Opdyke, Don Roberts

Publisher Resources

ISBN: 0321146530Purchase book