testsigma
Topics
left-mobile-bg

How to write Test cases for mobile number

July 17, 2024Amy Reichert
right-mobile-bg
Test Case For Mobile Number
image

Start automating your tests 10X Faster in Simple English with Testsigma

Try for free

Testing mobile phone number fields sounds simple and it is, but it can be complex if multiple locations (countries) are supported. Phone number formats are often different depending on the country or nation. Supported locations make a difference when testing phone number formats, number entry patterns, and error messaging based on type and location.

Test cases for mobile numbers vary based on a user’s global location (country). The application design or requirements are likely based on a specific location or multiple locations. If your documentation doesn’t specify, ask the product manager, designer, or developer for all supported locations to test against. 

What is a Mobile Number Field

A mobile number field is a representation of a user’s phone number. The format, style, and characters accepted change based on specific application requirements and whether the application is using the E.164 (The International Public Telecommunication Numbering Plan) standard and/or the NANP (North American Numbering Plan). 

Test cases for mobile phones need to consider both the E.164 and NANP if the application is sold globally. The E.164 sets a number limit of 15 characters including a three-digit country code. All nations using the NANP have a country code of 1 and a ten-digit number character limit. The first set of numbers represent the country code followed by the regional code and then the phone number. 

Test Cases For the Mobile Number Field

Phone number test cases are assumed in this blog to support both the E.164 and the NANP. We’ve listed the valid test cases first, followed by a few suggested tests for negative or error messaging testing. 

Mobile number test cases for functional testing include:

  • Verify the mobile phone field exists and accepts data entry.
  • Enter a valid phone format for a specific location (US and other nations)
    • Verify the user must include the country or area code. 
    • Verify NANP standards apply to the United States, Canada, and Jamaica.
    • Verify E-164 standards apply to all other countries. 
    • Verify any countries that don’t follow the E-164 standard. 
  • Copy and paste a valid number from a different form field.
  • If the mobile number field is required, verify there is a visual indicator to let the user know valid data must be entered.
  • Depending on the field design, including special characters to separate numbers like parentheses and dashes:
    • Example: (202) 444-9876.
  • If the application uses drop down selectors, select a valid country and enter a valid number for that location.
  • Select the country code dropdown and view the list of supported country formats. 
    • Verify the list is in alphabetical order for easier viewing. 
    • Verify the number selected displays in the field as expected. 
  • Test that the tab order stops in the mobile phone field and allows the user to enter a valid number. 
  • View the field and check that it aligns as expected with other fields and within a group. 

Mobile number negative test cases include:

  • Exceeding the allowed character limit.
  • Entering a correct country or area code with an invalid number for that location.
  • Enter an invalid country or area code with a valid number.
  • Enter in numeric characters with alpha characters.
    • Example: 1404abc9877.
  • Enter a valid country code and a phone number that’s one or more numbers to short for the selected location. 
  • Enter a valid country code and a phone number that exceeds the character limit for the location.
  • Enter a valid phone number but include various special characters (!@#$%^&*())
    • Example: 1720(3457)
    • Example: 005588#
  • Enter as many characters as the field allows up to 100. 
    • This test sounds silly, but it’s a good way to verify that the application is coded to avoid mass data entry. 
  • Enter a scripted SQL or HTML coded string. 
    • This test checks that the field does not execute code. 
    • Example: 18084560<bold>97</bold>
  • If the mobile phone field is required, try to enter and save information without filling it in. 
    • Optionally, try filling the mobile phone field with invalid data or partial valid numbers. 

For each negative test case, verify an error message is triggered indicating the error so the user can understand the problem and make corrections. Remember it’s good practice to have a peer or developer to review test cases when possible. The better the test case, the better the test coverage. 

Manual and Automated 

The table below gives you an example of typical test scenarios for creating manual test cases for mobile numbers:

Test IDDescriptionExpected Result
1Verify the mobile phone field exists and accepts data entry.Confirm the field exists and is enabled to allow users to enter data. 
2Enter a valid phone format for each specific location format supported. Verify each supported format allows users to enter a valid phone number into the field without resulting in an error. 
3If the application uses drop down selectors, select a valid country and enter a valid number for that location.Select each drop down option in turn and verify it matches with a valid phone number. Confirm no error messages are generated. 
4Test that the tab order stops in the mobile phone field and allows the user to enter a valid number.Tab through the form or page fields and verify it lands as expected in the mobile phone field. Enter a valid number and verify no errors are generated. 

The above table is a sampling only. You can write as many test cases as you need to cover requirements and standard functionality within your application. Additionally, you can create test cases in a design that fits with your development and QA team. 

Creating test cases for mobile phones are excellent candidates for test automation. For creating test cases for mobile phones consider using Low code test automation platform, Testsigma and organize your tests in the following modular flow as below:

Test IDDescriptionExpected Result
1Click into the mobile phone field. Enter test data for a valid US based phone number: 1+(309)665-9087Validate the correct phone number displays and is saved without error. 
2Click into the mobile phone field. Enter test data for a valid UK phone number: +44  20 7123 4567
NOTE: Consider using Testsigma’s automation tool to run through all valid formats in a single test. Add validation points for each valid type. 
Validate the correct phone number displays and is saved without error. 
3Create a test script that enters all required fields with valid data including the mobile phone field. 
Click the Save/Submit button when all fields are filled. 
Verify for each supported format type the application enters valid data into the database and saves/submits without error. 
4In the application form, enter valid phone numbers for each supported location type but leave off at least one digit.Validate each supported format type generates the correct error message. 
Enter a validation point for each format’s specific error message. 

Note, the above is a sample. You can learn how to use Testsigma to create automated scripts for each manual functional test – both positive and negative. Remember to create the relevant test data and ensure the data can be reset or refreshed for future automated test execution runs. 

Automate your mobile tests 10x faster

Check out Testsigma

Summary

Phone number test cases at first seem quite easy and simple. However, once you start testing for all supported formats, there is a great deal of testing to cover. Due to mobile phone number test cases being repetitive, consider using Testsigma to create automated test scripts. 

The first step for either automated or manual testing is understanding the relevant requirements and creating a thorough set of test data. 

Testers don’t have the luxury of time to continually look up valid phone numbers for every location or country/region. Save your testing time by creating a full set of valid numbers or generating them using a test automation tool. Ensure you have fully covered testing in the field using both positive, negative, and error messaging test cases. 

Frequently Asked Questions

What are the negative test cases for the phone number field?

Test cases for mobile numbers are considered negative whenever the format or character type is invalid. A negative test can also be a violation of the character length.

imageimage
Subscribe to get all our latest blogs, updates delivered directly to your inbox.

RELATED BLOGS


Test Evidence – What it is, Why & How to Capture?
KIRUTHIKA DEVARAJ
TESTING DISCUSSIONS
Tips for Writing Test Cases for Coffee Machines
AMY REICHERT
TESTING DISCUSSIONS
Salesforce Integration Testing | What it is & How to Perform?
PRIYANKA
TESTING DISCUSSIONS