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?
You can approach this by adding another dimension when creating the equivalence classes. Consider 3 possibilities of the field in question:
N = 0
= no product in stockN = 1
= only one product in stockN > 1
= several products in stockWriting 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.