How to write test cases for numeric and alphanumeric fields on a Drupal site?

| | 2 min read

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

  1. Ensure that the lower value and higher value specified for the field are handled correctly.
  2. Ensure that a space/blank entry in the first position of numeric field is reported as an error.
  3. Ensure that fields with a blank in the last position are reported as an error.
  4. Ensure that both positive and negative values are processed correctly according to the requirement.
  5. 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.
  6. Ensure that field accepts valid numbers.

Test cases for Alphanumeric fields

  1. Ensure that the field does not accept blank data.
  2. Ensure that the lower value and higher value specified for the field are handled correctly.
  3. Ensure that the field does not accept special characters or symbols.
  4. Ensure that the field accepts only valid characters.
  5. Ensure that a space/blank entry in the first position of numeric field are reported as an error.
  6. 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