A Guide To Writing OTP Verification Test Cases

Person entering a test case for OTP verification code on a smartphone at a laptop

Quick Summary

A strong OTP test suite covers far more than the happy path. Test cases should address code generation, validation, expiry, retry limits, delivery timing, message formatting, and behavior across countries and carriers. Functional cases catch logic errors in the application, while live testing on real handsets catches the delivery failures that a staging environment cannot reproduce.

Most OTP test plans start and end with the same scenario: a user requests a code, receives it, types it in, and logs in. That path passes in every staging environment, which is exactly why it reveals so little. A well-built test case for OTP verification covers the failures that surround that path: late codes, expired codes, repeated attempts, and messages that never reach a handset. This guide walks through how to structure those cases, what each one should check, and where functional testing needs live network testing to finish the job.

At Global Telecom Testing, our OTP testing services run on real handsets and real carrier networks, which closes the gap a staging environment leaves open.

What Every OTP Test Case Should Contain

Each test case needs a fixed set of parts so any tester can run it and reach the same verdict:

  • Preconditions: account state, country, carrier, and device type
  • Steps: the exact sequence of actions, from requesting the code to submitting it
  • Expected result: a specific, observable outcome
  • Pass criteria: a measurable threshold, such as delivery time or digit count

Vague expected results cause disputes later. “User receives code” tells a tester very little. “Code arrives within 30 seconds, shows six digits intact, and comes from the registered sender ID” gives a clear pass or fail.

Core Functional Test Cases

Start with the logic inside the application itself. These cases are fast to run and easy to automate:

  • A correct code is accepted and completes the transaction.
  • An incorrect code is rejected with a clear, non-revealing error message.
  • A code requested earlier is rejected once a newer code has been issued.
  • A code is accepted just before its expiry time and rejected just after it.
  • A code that has already verified a session cannot be used a second time.

Code generation deserves its own cases too. Check that codes have the expected length, that they are unique per request, and that they do not follow a predictable pattern an attacker could guess.

Retry, Resend, and Lockout Test Cases

Retry behavior is where many authentication flows quietly break. Write cases for the resend button cooldown, for the point where a resend invalidates the previous code, and for the number of failed attempts that triggers a lockout. Then test the lockout itself: how long it lasts, what message the user sees, and how a legitimate user recovers.

Rate limiting on code requests belongs in this group as well. Without a cap, a compromised flow can be used to trigger large volumes of messages to premium-rate numbers, a fraud pattern known as SMS pumping. A test case that fires repeated requests from one account or one device, and confirms the system throttles them, protects both budget and delivery reputation.

Delivery and Timing Test Cases

This is the group where functional testing alone falls short. A sandbox number in a staging environment returns the code instantly every time, so every delivery case passes. Real subscribers experience something different, and the cases below only produce useful results when run against real handsets.

  • Delivery time stays within the authentication window in each target country.
  • The message arrives from the expected sender ID and not an unfamiliar number.
  • The code displays intact, without truncation or garbled characters, including in non-Latin scripts.
  • Delivery works on prepaid lines, MVNOs, and roaming subscribers, not only postpaid accounts.
  • Mobile autofill picks up the code correctly on both major operating systems.

Delivery varies by country because carriers apply their own registration rules, filtering, and routing. A code that arrives in two seconds in one market can take two minutes in another, and neither result shows up in a delivery receipt.

Edge Cases Worth Adding

Once the main groups are covered, add a short set of unusual conditions. Request two codes at nearly the same moment and confirm only the right one validates. Change the phone number partway through the flow.

Switch a phone into airplane mode after requesting a code, then reconnect and see what arrives. Paste a code with a trailing space. Run the whole flow with a screen reader. Each of these takes minutes to write and tends to uncover defects that the standard cases skip.

Where Test Cases Need Real Networks

A test suite for OTP verification has two layers. The first checks that the application generates, validates, expires, and limits codes correctly. The second checks that the codes reach people. The first layer lives in your codebase and your staging environment. The second lives on carrier networks in each country you serve, and it can only be tested from those networks.

Record results for both layers in the same format, and rerun the delivery cases on a schedule. Carrier filtering rules and sender ID requirements change over time, so a market that passed last quarter is not guaranteed to pass today.

How GTT Supports OTP Verification Testing

At Global Telecom Testing, we built our OTP testing around the second layer. Our local, in-country testers use real handsets on real carrier networks in more than 200 countries to run the delivery, timing, sender ID, and formatting cases described above through our SMS testing, then report what arrived and how long it took.

If your functional test cases are solid but your delivery results come from a staging environment, we’d welcome the chance to run a trial test in the markets you care about most.

FAQs

How many test cases does an OTP verification flow need?

There is no fixed number, but a thorough suite usually covers five groups: code generation and validation, expiry, retry and lockout behavior, delivery and timing, and edge cases. Each group typically contains several cases, and the delivery group should be run separately for each target country.

Pass criteria should come from your own authentication window. If a code expires after two minutes, a threshold such as delivery within 30 seconds leaves room for a user to read and enter it. Set the threshold per market, since normal delivery speed differs between countries.

Functional cases such as validation, expiry, single-use enforcement, and lockout are well suited to automation. Delivery cases need real handsets on real carrier networks to produce meaningful results, so they are best handled through live testing alongside the automated suite.

Carriers in each country apply their own routing, filtering, and registration rules, so a code that arrives quickly in one market can arrive late or not at all in another. A staging environment cannot show that difference. Testing from inside each country shows what a real recipient receives and how long it takes. At Global Telecom Testing, our local, in-country testers can run these delivery checks in more than 200 countries.

Recent Articles

Before you go:
Schedule a free trial test

with the only company worldwide testing in 200 countries.

800

local staff

200

countries

35+

years of experience