Cycle, Rinse, Repeat

images/tdd/twonumbers.png

OK, here is test number two. This is just like test number one, except now we want to enter two numbers in our calculator, and ensure that the second number is the one that would show up on our display.

First step is to write a failing test.

images/tdd/step1.png

OK, good. We’ve got our failing test. Now we just need to make it pass. Which we can by instead returning the last element added to our array and not the first. Like this.

images/tdd/step2.png

Now we are ready ...

Get The Way of the Web Tester now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.