blog
OTP testing and OTP checker workflows for email, SMS, magic links, and MFA
Use OTP testing and OTP checker workflows to validate email codes, SMS verification, magic links, MFA, expiry, resends, and one-time use.
If you searched for otp testing, otp checker, mfa testing, email otp testing, or sms otp testing, you are probably trying to solve one of two problems:
- prove that auth and recovery flows work before release, or
- stop brittle OTP checks from breaking CI and staging runs.
This guide explains what OTP testing should cover, how it differs from broader MFA testing, and how to build deterministic checks for email, SMS, and time-based codes.
Quick answer
Good OTP testing should prove that:
- the right code or link is sent to the right channel
- the code arrives within an acceptable time budget
- the token expires when it should
- retries and resends behave correctly
- one-time use is enforced
- rate limits and abuse controls work
- the full signup, login, or recovery workflow completes successfully
If you only check that "a code was sent," you will miss the failures that matter most.
An OTP checker is useful only when it checks the delivered artifact and the surrounding journey. For email and SMS, that means waiting for the real message, extracting the code or link, submitting it back into the app, and asserting the final state.
OTP checker workflow with MailSlurp
An OTP checker should answer more than "does this string look like a six-digit code?"
With MailSlurp, the checker can use real inboxes and phone numbers that are controlled by your tests:
| Channel | What MailSlurp verifies | Common use case |
|---|---|---|
| Email OTP | The verification email arrives, the code or link can be extracted, and the account step completes | Signup, login, invite, and password reset testing |
| SMS OTP | The SMS arrives on a real test number, the code is parsed, and the verification screen accepts it | Phone verification, MFA, and recovery checks |
| Magic links | The delivered link points at the right environment, expires correctly, and opens the expected session | Passwordless login and account activation |
| TOTP | The authenticator secret is enrolled and rolling codes work inside the valid time window | MFA setup, reset, and recovery testing |
The basic MailSlurp pattern is:
- create a fresh inbox, phone number, or TOTP device for the test
- trigger the signup, login, reset, or recovery step
- wait for the exact message or code
- extract the OTP or link
- complete the user workflow
- assert success, expiry, resend behavior, and saved evidence
Start with Authentication testing when you need the full email, SMS, magic-link, and MFA model. Use the SMS verification API when the primary risk is phone verification.
When you need an OTP verification API
An OTP verification API is the implementation layer behind the test. It should make the auth journey observable from code:
- create or assign a MailSlurp inbox, phone number, or TOTP device
- trigger the signup, login, recovery, or MFA challenge
- wait for the delivered email or SMS
- extract the OTP code or magic link
- submit the value to the verification endpoint
- assert the account, session, or recovery state changed correctly
This matters because OTP bugs rarely live in one function. They show up when delivery is delayed, the template changes, a resend leaves two valid codes, or a fallback path points at the wrong environment.
Use SMS and OTP verification API for phone-first flows, Email integration testing for inbox-first flows, and Authentication testing when the same release needs email, SMS, magic-link, and MFA coverage.
OTP checker vs OTP test
An OTP checker usually means a narrow step: read a one-time code and decide whether it matches the expected format.
An OTP test should cover the complete user journey.
| Step | OTP checker | Complete OTP test |
|---|---|---|
| Trigger signup, login, or reset | Sometimes | Yes |
| Wait for real email or SMS delivery | Yes | Yes |
| Extract the code or magic link | Yes | Yes |
| Submit the code back into the app | Rarely | Yes |
| Assert expiry and one-time use | Rarely | Yes |
| Assert final app state | Rarely | Yes |
| Capture evidence for CI failure review | Rarely | Yes |
For production auth flows, use the complete test. The code itself is only one part of the risk.
What OTP testing actually means
OTP testing is the process of validating one-time-password or one-time-code flows under realistic conditions.
That usually includes:
- email OTP codes
- SMS verification codes
- magic links
- recovery codes
- MFA or 2FA prompts tied to authenticator apps
In practice, teams are not only testing the code itself. They are testing the delivery path, expiry rules, user journey, and error handling around the code.
OTP testing vs MFA testing vs TOTP testing
These terms overlap, but they are not identical.
OTP testing
Focused on one-time codes or links used to verify a user action.
Examples:
- signup verification code
- login OTP
- password reset code
- email confirmation link
MFA testing
Focused on the wider multi-factor flow, including:
- factor enrollment
- factor selection
- challenge and response
- fallback or recovery
- account lockout and retry behavior
TOTP testing
Focused on time-based one-time passwords generated from a shared secret, usually in an authenticator app.
Examples:
- Google Authenticator
- Authy
- Microsoft Authenticator
- in-app TOTP device enrollment
If your product uses authenticator apps, see TOTP and authenticator device testing.
Why OTP testing matters
OTP failures do not just create "minor auth bugs." They hit important business paths:
- new-user activation
- account access and login
- password reset
- payment and payout confirmation
- security-sensitive account actions
When those flows fail, the result is usually immediate:
- lower signup conversion
- higher support volume
- false fraud flags
- broken CI release gates
- lost confidence in the auth system
That is why otp testing should be treated as a release-risk topic, not a niche security afterthought.
What to test in an OTP workflow
1. Delivery and arrival
Start with the obvious question: does the code or link actually arrive?
Test:
- delivery to the correct email address or phone number
- acceptable latency under normal load
- delivery under staging and CI conditions
- provider-specific failures or delays
For email and SMS flows, MailSlurp gives teams real inboxes and real phone numbers that can be controlled in code:
2. Extraction
The next problem is reading the code or link reliably.
Test:
- code extraction from plain text and HTML email
- SMS code extraction from message body
- magic-link parsing
- template changes that move or rename important content
This is where brittle regex-only checks often break. You want deterministic assertions with known subjects, sender filters, and message matching rules.
3. Expiry and one-time use
One-time codes are not only about delivery. They are security controls.
Test:
- token expires after the expected TTL
- expired code is rejected
- successful use invalidates the token
- previously sent codes do not remain valid after resend
These checks catch a surprising number of production regressions, especially after auth refactors.
4. Retry, resend, and lockout behavior
Users do not always succeed on the first attempt. Good OTP testing must cover the real retry lifecycle.
Test:
- resend cooldowns
- invalid attempt counters
- account lock or step-up friction after repeated failure
- user-visible error messaging
- supportable recovery paths
5. Workflow completion
The final question is not "did we send a code?" It is "did the user complete the intended workflow?"
Test the full path:
- create account
- trigger verification
- receive code or link
- submit or open it
- reach the success state
This is why OTP testing belongs in end-to-end testing, not just unit tests on token generation.
Email OTP testing
Email OTP flows are common for:
- signup confirmation
- magic link login
- account recovery
- device verification
The main risks are:
- code not arriving
- wrong sender or subject causing filters to miss the message
- HTML/template changes breaking extraction
- verification links pointing at stale environments
Good email OTP testing uses fresh inboxes per run instead of shared QA accounts. That removes flaky state and makes message matching reliable.
Useful starting points:
SMS OTP testing
SMS OTP flows are common for:
- login verification
- signup confirmation
- account recovery
- step-up security checks
The main risks are:
- delayed delivery
- resend confusion
- region or carrier differences
- number formatting issues
- tests depending on one shared phone number
For those flows, you want real numbers under API control, not fake test doubles.
SMS test scenarios for OTP and MFA
When teams search for sms test, test sms, or otp test, the useful scenarios are usually specific:
| Scenario | What to assert |
|---|---|
| Signup SMS verification | Code arrives, matches the created user, and completes activation |
| Login OTP | Code arrives within the time budget and one-time use is enforced |
| Password reset SMS | Reset code or link expires correctly and cannot be reused |
| Resend flow | New code invalidates the previous code and cooldown behavior is correct |
| Region formatting | Phone number normalization works for the target country or carrier |
| Abuse control | Invalid attempts, rate limits, and lockouts behave predictably |
Use a dedicated phone number per run when possible. Shared numbers make parallel tests flaky and can hide resend or reuse bugs.
Useful starting points:
Magic link testing
Some teams search for otp testing when the real artifact is a magic link rather than a numeric code.
Magic-link testing should cover:
- correct destination environment
- one-time use
- expiry
- invalidation after password change or session change
- link extraction from HTML and text fallbacks
This is usually best handled with the same inbox-based testing pattern used for email OTP.
TOTP and authenticator app testing
TOTP is different because the code is generated from a shared secret and time window, not delivered through email or SMS.
Test:
- factor enrollment
- QR secret handoff
- correct time-window validation
- drift tolerance
- backup and recovery factors
- device reset or re-enrollment
If your system uses authenticator apps, do not rely on only one happy-path login test. TOTP flows often fail around enrollment, reset, and secret rotation.
See:
How to automate OTP testing in CI
The safest pattern is:
- provision a fresh inbox or phone number
- trigger the auth workflow in your app
- wait for the expected email or SMS using deterministic filters
- extract the code or link
- submit it back into the app
- assert the authenticated or recovered state
This works well in Playwright, Cypress, Selenium, Postman-driven workflows, and other framework stacks.
The most reliable implementation keeps the OTP checker close to the real product path. If the customer signs up through a browser, run a browser test. If the flow is API-first, call the verification endpoint after MailSlurp receives the code. In both cases, use fresh MailSlurp resources so parallel runs do not read each other's messages.
Good framework entry points:
- Playwright email testing
- Cypress email testing
- Selenium email testing
- SMS testing tutorial
- Authentication testing solution page
OTP testing by framework
The test shape is the same across tools: create a controlled inbox or phone number, trigger the app workflow, wait for the delivered code, submit it, and assert the final state. The implementation details differ by runner.
| Tool | Best OTP testing fit | Useful MailSlurp path |
|---|---|---|
| Playwright | Browser-driven signup, login, reset, SMS, and magic-link checks | Playwright email and SMS testing |
| Cypress | Frontend CI checks that need stable inboxes and reusable commands | Cypress email and SMS testing |
| Selenium | Java, C#, and enterprise browser suites that need real email or SMS receipt | Selenium email and SMS testing |
| Postman or API tests | Auth API flows where the test runner needs to fetch the delivered code programmatically | Postman MFA testing guide |
| ACCELQ, Tosca, Robot Framework, and UiPath | No-code, low-code, or enterprise QA flows that need email and SMS verification steps | ACCELQ email testing |
If your team uses several runners, keep the same MailSlurp primitives across them: one inbox or number per run, deterministic waits, code extraction, retry coverage, and saved message evidence.
Postman and API-driven OTP checks
OTP testing does not always need a browser. API teams often use Postman, Newman, contract tests, or backend integration tests to validate the same delivery loop:
- call the signup, login, or reset endpoint
- wait for the email or SMS in MailSlurp
- extract the OTP code or magic link from the delivered message
- submit the code to the verification endpoint
- assert the account or session state
This is useful when the verification flow has a stable API contract and the team wants fast checks before slower browser suites run.
For API-driven OTP checks, keep the assertions product-specific:
- the requested user or phone number matches the delivered message
- the code format is correct for that flow
- the message arrives before the timeout
- the verification endpoint accepts the code once
- a reused, expired, or replaced code is rejected
- the account, session, or recovery state changes as expected
Common OTP testing failures
Shared test inboxes
Tests read the wrong code because multiple runs are using the same mailbox or number.
Resend logic not covered
The team tests first-send only, then production users trigger a resend bug that invalidates the wrong token.
Expiry not tested
The code works in one test path but remains valid for too long.
Extraction assumes one template
The parser works until the email or SMS copy changes slightly.
Happy-path only coverage
The team tests successful verification but never tests:
- wrong code
- expired code
- max attempts
- recovery path
- fallback factor
OTP testing checklist
Use this checklist before release:
- verify code or link arrives in the expected channel
- verify arrival time stays within budget
- verify extraction is deterministic
- verify expiry works
- verify one-time use is enforced
- verify resend invalidation rules
- verify lockout and retry behavior
- verify success state in the real workflow
- verify failure states are understandable
- verify artifacts are captured for debugging
How MailSlurp helps
MailSlurp leads when teams need to move OTP testing out of manual QA and into repeatable automation.
Use it for:
- fresh inboxes and phone numbers per test run
- waiting for email or SMS messages with filters
- extracting OTP codes, magic links, and message content
- capturing evidence in CI and release workflows
- combining auth testing with rendering and deliverability checks
Good next steps:
- Authentication testing
- OTP testing solution
- Email integration testing
- Phone number and SMS service
- TOTP testing
- Create a free auth testing account
FAQ
What is OTP testing?
OTP testing is the process of validating one-time-password or one-time-code workflows, including delivery, extraction, expiry, one-time use, and successful completion of the surrounding user journey.
Is OTP testing the same as MFA testing?
Not exactly. OTP testing focuses on the one-time code or link. MFA testing covers the wider multi-factor flow, including enrollment, fallback, and factor management.
How do you test SMS OTP in CI?
Use real phone numbers that can be controlled in code, wait for the inbound SMS, extract the code, and complete the app flow automatically.
How do you test email OTP without flaky inboxes?
Create isolated inboxes per test run, filter messages deterministically, and assert the code or magic link in code instead of sharing one QA mailbox.
Should OTP testing include expiry and resend logic?
Yes. Those are some of the most important failure modes because they break real users even when initial delivery works.
Final take
The best otp testing approach is not about checking a six-digit code in isolation.
It is about proving that email, SMS, magic-link, and MFA workflows behave correctly under real conditions, with deterministic evidence the team can trust before release.