27.10.2014 Views

Cracking the Coding Interview, 4 Edition - 150 Programming Interview Questions and Solutions

Cracking the Coding Interview, 4 Edition - 150 Programming Interview Questions and Solutions

Cracking the Coding Interview, 4 Edition - 150 Programming Interview Questions and Solutions

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Solutions</strong> to Chapter 12 | Testing<br />

12.6 How would you test an ATM in a distributed banking system?<br />

SOLUTION<br />

pg 70<br />

The first thing to do on this question is to clarify assumptions. Ask <strong>the</strong> following questions:<br />

»»<br />

Who is going to use <strong>the</strong> ATM? Answers might be “anyone,” or it might be “blind people”<br />

- or any number of o<strong>the</strong>r answers.<br />

»»<br />

What are <strong>the</strong>y going to use it for? Answers might be “withdrawing money,” “transferring<br />

money,” “checking <strong>the</strong>ir balance,” or many o<strong>the</strong>r answers.<br />

»»<br />

What tools do we have to test? Do we have access to <strong>the</strong> code, or just <strong>the</strong> ATM machine?<br />

Remember: a good tester makes sure she knows what she’s testing!<br />

Here are a few test cases for how to test just <strong>the</strong> withdrawing functionality:<br />

»»<br />

Withdrawing money less than <strong>the</strong> account balance<br />

»»<br />

Withdrawing money greater than <strong>the</strong> account balance<br />

»»<br />

Withdrawing money equal to <strong>the</strong> account balance<br />

»»<br />

Withdrawing money from an ATM <strong>and</strong> from <strong>the</strong> internet at <strong>the</strong> same time<br />

»»<br />

Withdrawing money when <strong>the</strong> connection to <strong>the</strong> bank’s network is lost<br />

»»<br />

Withdrawing money from multiple ATMs simultaneously<br />

CareerCup.com<br />

2 1 4

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!