Chapter 12

Addition, Finally

It’s a new day, and our to-do list has become a bit cluttered, so we’ll copy the pending items to a fresh list. (I like physically copying to-do items to a new list. If there are lots of little items, I tend just to take care of them rather than copy them. Little stuff that otherwise might build up gets taken care of just because I’m lazy. Play to your strengths.)

I’m not sure how to write the story of the whole addition, so we’ll start with a simpler example: $5 + $5 = $10.

public void testSimpleAddition() {
   Money sum= Money.dollar(5).plus(Money.dollar(5));
   assertEquals(Money.dollar(10), sum);
}

We could ...

Get Test Driven Development: By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.