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