Test Stack

Problem

A developer has written a stack designed to hold a maximum of five variables and he has asked you to test it. How would you test that stack?

Solution

Here are the general guidelines to test the stack. Note that they can be applied to testing software components in general:

A. If white box testing is needed then I would come out with the minimum required test cases that achieve 100% path coverage by evaluating the execution flow of the code along with its cyclomatic complexity. I do not want to elaborate on this point as it is implementation specific. For example the stack can be implemented using an array or a linked list

B. Testing the stack as a black box requires the QA engineer to think about the following important scenarios:

  1. Write individual test cases to cover the basic stack operations such as pop, push, peek, length, etc. In other words, we need to maintain the tractability between the test cases and the software (stack in this case) requirements
  2. Write test cases to check out boundary values for example pushing 6 elements to see if stack overflow is handled properly
  3. Doing some equivalence partitioning related testing which means electing a single point from each partition of the input range. For example if the stack expects integer numbers then a negative number, a zero and a positive number should be considered
  4. Write test cases to do negative testing where invalid or random input is used to test the stack

Add a Comment

Your email address will not be published. Required fields are marked *