Most of the time we starting writing test cases based
on our experience and intuition and sometimes we end up writing some useless or
repetitive test cases (in the sense that specific scenario might have already
been covered in some other test case). I am not saying that we should not use
our past experience but experience should be used along with some scientific
techniques.
There are many techniques which can be used (and
should be used) to write test cases (especially test data). These are mainly
test data generation techniques which should be used to write effective and
optimized test cases. Some of the techniques are like Boundary value analysis,
equivalence partitioning, orthogonal arrays etc.
BVA and EP should be used to generate valid and
invalid data for each field. Orthogonal array is used when we have multiple
fields on the screen and we want test data with different combinations.
Boundary Value Analysis:
In BVA, we generate test data at the boundary of the field i.e. if any field
accepts numeric value between 18 and 60 then test data for that field should be
17,18,60,61.
Equivalence Partitioning:
In EP, first we determine valid range of the field for example in our example
valid range is 18 to 60 so test data should be selected as:
Valid range: 18-60: any one value
Invalid range1: -ve no. to 17: any one value
Invalid range2: 61 to +ve no.: any one value
Invalid range3: any alphanumeric value
Orthogonal Arrays: Above two techniques
are used only for single field. For different combination of multiple fields
orthogonal arrays are used. For example if there are 5 fields on a screen then
orthogonal arrays should be used to come up with minimal test data required to
cover maximum test functionality. There are various tools like AllPairs which
generate test data for combination of fields. AllPairs is a very simple and
free to use tool which reads data for each field from file and generate test
data file.
Finally some test cases should be created based on
experience. Some of the examples are:
1. If field accepts alphanumeric values then some test
cases for:
a. Special characters
b. Escape characters
c. Specific special characters combination like ';-- (database comment)
d. leading/ trailing blank spaces
e. foreign characters
and some other project specific special requirements.