How to write test cases for numeric and alphanumeric fields on a Drupal site?
Testing is a very significant phase in the development of Drupal based websites. In this article we are going to discuss how to write test cases for numeric and alphanumeric fields on a Drupal site
If a field signifies a particular input type then we should ensure that it does not accept values other than specified. For example, if you have a field for entering numeric values, it should accept only digits/numbers. Here, I have documented on the test cases which are commonly used to check the numeric and alphanumeric field validations. These test cases are applicable for both Drupal and non Drupal sites.
Test cases for Numeric Fields
- Ensure that the lower value and higher value specified for the field are handled correctly.
- Ensure that a space/blank entry in the first position of numeric field is reported as an error.
- Ensure that fields with a blank in the last position are reported as an error.
- Ensure that both positive and negative values are processed correctly according to the requirement.
- If a field functions like a calculator then ensure that:
- The system does not crash on dividing a number by zero.
- The field generates the value zero on multiplying a number with zero.
- Ensure that field accepts valid numbers.
Test cases for Alphanumeric fields
- Ensure that the field does not accept blank data.
- Ensure that the lower value and higher value specified for the field are handled correctly.
- Ensure that the field does not accept special characters or symbols.
- Ensure that the field accepts only valid characters.
- Ensure that a space/blank entry in the first position of numeric field are reported as an error.
- Ensure that fields with a blank in the last position are reported as erroneous.
By executing all these cases, we can assure that field accepts only specified values. But the above cases are for default numeric and alphanumeric fields and test cases may vary according to the requirement given by the client. So always keep in mind that we should write test cases against the requirements/customization specified.
Hope this article was useful. Use the comment form below to give feedbacks