O'Reilly logo

Test Driven Development: By Example by Kent Beck

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 12. Addition, Finally

$5 + 10 CHF = $10 if rate is 2:1

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.)

$5 + 10 CHF = $10 if rate is 2:1$5 + $5 = $10

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 fake the ...

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