How to Test Otp Verification on Android (Complete Guide)

One-Time Password (OTP) verification is a critical security layer for modern Android applications. It protects user accounts from unauthorized access, validates sensitive transactions, and enhances ov

April 22, 2026 · 6 min read · How-To Guides

Mastering OTP Verification Testing on Android

One-Time Password (OTP) verification is a critical security layer for modern Android applications. It protects user accounts from unauthorized access, validates sensitive transactions, and enhances overall user trust. However, poorly implemented OTP flows can lead to significant user frustration, account lockouts, and security vulnerabilities. Comprehensive testing is paramount to ensure a robust and user-friendly OTP experience.

The Stakes of Inadequate OTP Verification Testing

Failures in OTP verification can have immediate and damaging consequences:

Comprehensive OTP Verification Test Cases for Android

A thorough test suite for OTP verification should cover a wide spectrum of scenarios:

#### Happy Path Scenarios

  1. Successful OTP Entry: User initiates OTP request, receives it promptly, and enters the correct code within the allowed time limit. App proceeds to the next validated step.
  2. Resend OTP Functionality: User requests a new OTP after the initial one expires or is not received. The new OTP is generated and delivered, and the user successfully verifies.
  3. Auto-Detection (if applicable): For SMS-based OTPs, the app automatically detects the incoming SMS and pre-fills the OTP field. User confirms or completes verification.

#### Error Scenarios

  1. Incorrect OTP Entry (Multiple Attempts): User enters an incorrect OTP multiple times. Verify that the app provides clear error feedback and appropriately limits further attempts (e.g., temporary lockout).
  2. Expired OTP: User attempts to enter an OTP after its validity period has passed. The app should reject the OTP and prompt the user to request a new one.
  3. Invalid OTP Format: User attempts to input characters or a number of digits that do not match the expected OTP format. The app should reject invalid input.
  4. Network Interruption During OTP Entry: Simulate network loss while the user is entering the OTP. Verify app behavior upon network restoration – does it resend the OTP, maintain the entered digits, or reset?
  5. SMS Delivery Failure: Test scenarios where the SMS gateway fails to deliver the OTP to the user's device. This is harder to simulate directly but can be indirectly tested by observing delays or timeouts.

#### Edge Cases

  1. Rapid OTP Requests: User repeatedly requests an OTP within a short period. Verify that the system handles this gracefully, potentially with rate limiting or clear messaging about wait times.
  2. Background/Foreground Switching: User navigates away from the OTP screen and returns. Verify that the entered OTP digits are preserved, or the app provides a clear state reset.
  3. Device Language/Region Settings: Ensure OTP prompts and error messages are correctly localized based on device language and region settings.

#### Accessibility Considerations for OTP Verification

  1. Screen Reader Compatibility: Verify that all OTP-related UI elements (input fields, buttons, error messages, instructions) are properly labeled and navigable using screen readers like TalkBack.
  2. Sufficient Time Limits: Ensure the OTP expiry time is generous enough for users with cognitive impairments or those using assistive technologies to input the code without undue pressure.
  3. Clear Error Messaging: Error messages should be concise, easy to understand, and actionable for users with visual impairments or cognitive differences.

Manual Testing Approach for OTP Verification

A structured manual testing process can uncover many of these issues:

  1. Environment Setup: Use a real Android device or a reliable emulator. Ensure you have a valid phone number registered for receiving test SMS messages.
  2. Initiate OTP Flow: Navigate to the screen where OTP verification is required (e.g., login, password reset, transaction confirmation).
  3. Request OTP: Trigger the OTP request.
  4. Monitor OTP Delivery: Observe the device for the incoming SMS. Note the time taken for delivery.
  5. Enter OTP:
  1. Observe System Response:
  1. Test Resend Functionality: After an OTP expires or is deliberately not used, trigger the resend option. Verify the new OTP is received and works.
  2. Simulate Interruptions: During OTP entry, switch apps, turn on airplane mode, or disable Wi-Fi/mobile data. Observe how the app recovers when connectivity is restored.
  3. Accessibility Testing: Use TalkBack to navigate and interact with all OTP-related UI elements. Ensure all labels and instructions are announced correctly. Test with different font sizes and display settings.
  4. Edge Case Testing: Rapidly request OTPs, switch between apps during entry, or test with varying device language settings.

Automated Testing for Android OTP Verification

Automating OTP verification testing is crucial for efficiency and continuous integration.

Example (Conceptual Appium Snippet - Python):


from appium import webdriver
from appium.webdriver.common.appiumby import AppiumBy
import time

# ... (driver initialization) ...

# Assume 'otp_input_field' is the accessibility ID for the OTP input
otp_input_field = driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value="otp_input_field")
otp_input_field.send_keys("123456") # Replace with actual retrieved OTP

# Assume 'verify_button' is the accessibility ID for the verify button
verify_button = driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value="verify_button")
verify_button.click()

# Assert successful verification or error message

How SUSA Tests OTP Verification Autonomously

SUSA (SUSATest) approaches OTP verification testing through its autonomous exploration engine, leveraging diverse user personas to uncover issues that manual or script-based testing might miss.

By integrating SUSA into your QA pipeline, you gain continuous, comprehensive testing coverage for critical OTP verification flows, significantly reducing the risk of user lockouts and security breaches.

Test Your App Autonomously

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.

Try SUSA Free