How to test an ATM in a distributed banking system

Problem How would you test an ATM in a distributed banking system? Solution The first thing to do on this question is to clarify assumptions Ask the following questions: Who is going to use the ATM? Answers might be “anyone”, or it might be “blind people” – or any number of other answers What are they going to use it for? Answers might be “withdrawing money”, “transferring money”, “checking their balance”, or many other answers What tools do we have to test? [Read More]

How to test a pen

Problem How would you test a pen? Solution This problem is largely about understand the constraints: what exactly is the pen? You should ask a lot of questions to understand what exactly you are trying to test To illustrate the technique in this problem, let us guide you through a mock-conversation. Interviewer: How would you test a pen? Candidate : What kind of pen is it? Is it a ball pen, pilot pen, roller pen, sketch pen? [Read More]

Load test a webpage without using any test tools

Problem How would you load test a webpage without using any test tools?  Solution Load testing helps to identify a web application’s maximum operating capacity, as well as any bottlenecks that may interfere with its performance. Similarly, it can check how an application responds to variations in load. To perform load testing, we must first identify the performance-critical scenarios and the metrics which fulfill our performance objectives. Typical criteria include: [Read More]

How to test a canMoveTo(int x, int y) method in a chess game

Problem We have the following method used in a chess game: boolean canMoveTo(int x, int y) x and y are the coordinates of the chess board and it returns whether or not the piece can move to that position. Explain how you would test this method.  Solution There are two primary types of testing we should do: Validation of input/output: We should validate both the input and output to make sure that each are valid. [Read More]

Find the mistake(s) in the code

Problem Find the mistake(s) in the following code: unsigned int i; for ( i = 100; i <= 0; --i) printf("%d\\n", i); Solution Because i is an unsigned integer, i cannot be negative. Hence the for loop should be: for ( i = 100; i >= 0; --i) As i is unsigned integer, when i == 0 and one does –i, i will be FFFF FFFF in hex. Then when you do printf with “%d”, i will be interpret as an signed integer. [Read More]

Programming errors cause program crashes in different places every single time

Problem You are given the source to an application which crashes when it is run. After running it ten times in a debugger, you find it never crashes in the same place. The application is single threaded, and uses only the C standard library. What programming errors could be causing this crash? How would you test each one? Solution The question largely depends on the type of application being diagnosed. [Read More]