Question

I have an input value I wish to test where the acceptable range is 1..n (n is variable but always positive). To give it some context, n is the quantity of a product in stock at any one time (which changes day to day). A user may request to use 1 or up to n of these products at any one time but should be restricted if they request more than the value of n at that time.

To create test cases for the input value I thought I would apply equivalence partitioning and boundary value analysis to create classes and select the boundary values. However, I am not sure how you use these techniques to define test cases when the equivalence classes/boundary values of an input is variable.

Are the EP/BV techniques not applicable for this type of situation? How would one approach defining values for a test case?

Was it helpful?

Solution

You can approach this by adding another dimension when creating the equivalence classes. Consider 3 possibilities of the field in question:

  1. N = 0 = no product in stock
  2. N = 1 = only one product in stock
  3. N > 1 = several products in stock

Writing tests for (1) and (2) is trivial, you already know how to get the boundaries. For covering (3), you can pick any N > 1 and identify the boundaries for it.

The actual value chosen for N (when N > 1) is not important (unless you want to cover field overflow - e.g. integer overflow), so you will simply control it on your preparation steps and/or test data.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top