testsigma
Topics
left-mobile-bg

How to Write Test Cases For Email Field and Email Validation

June 27, 2024Ritika Kumari
right-mobile-bg
Testcases for email
image

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

Try for free

If you have a business, you might also have a list of customer emails. This directory of email addresses enables businesses to nurture their leads through the marketing funnel. New emails get added to this list as new users come to the website and fill out the forms (sign up, demo) that include an email field. Any issues with this field will result in the erosion of the quality of the email list and, ultimately, the loss of clients. No company wants that!

Proper testing and validation of email fields throughout the company website is the only way to eliminate the loss of qualified leads. Learn and run these test cases for the email field discussed below. You can also follow test case design techniques to create them.

Test Cases For Email Field

The email field is a critical input criterion to fulfill for any new (sometimes existing) user to enter the funnel. If the field contains bugs that stop users from entering their emails or does not add the entered address automatically to the email list, your business is headed to a huge loss. 

Create and execute the below positive, negative, and design-related test cases for the email ID field to prevent any mishaps. For the same, some of these test case templates might come in handy.

Positive Test Cases For Email Field

  • Verify that the field accepts a valid email address.
  • Test multiple valid email formats (e.g., user@domain.com).
  • Confirm that the email field is case-insensitive.
  • Validate the acceptance of special characters.
  • Test email submission with leading and trailing spaces.
  • Verify that the system accepts a correct email with a subdomain.
  • Confirm that emails with a valid top-level domain (TLD) are accepted.

Negative Email ID Test Cases

  • Attempt to submit an email without the “@” symbol.
  • Test an email without a domain (e.g., user@).
  • Verify rejection of emails without a local part (e.g., @domain.com).
  • Submit an email with spaces within the address.
  • Test email submission with invalid characters (e.g., user#domain.com).
  • Confirm rejection of emails with consecutive dots (e.g., user..@domain.com).
  • Attempt to submit an email with an invalid top-level domain (e.g., user@domain.c).
  • Validate the appearance and alignment of the email field on different screen sizes.
  • Confirm that proper error messages are displayed for invalid email submissions.
  • Test the responsiveness of the email field on various devices.
  • Check if the email field label is clear and appropriately positioned.
  • Test the behavior of the email field with autofill and autocomplete features.
  • Validate that the email field has an appropriate length to accommodate common email addresses.
  • Test the autocomplete suggestions provided by browsers for the email field.

Testers can run all the positive, negative, and UI test cases either manually or automatically. For automation, Testsigma is the choice for many. It requires no coding, supports a myriad of testing scenarios, and offers 24/7 customer support. The tool is useful for:

  • Web automated testing along with mobile and API testing
  • Automates tests 10x faster with high accuracy
  • Offers pre-defined NLPs for testers to work with
  • Integrates with CI/CD pipelines to assist your DevOps team
  • Uses AI for producing high-quality test cases that offer the best results

Here is the Testsigma dashboard with NLPs that make testing effortless for you

Testing dashboard

What is Email Validation?

After email field testing is complete, email validation comes. It is the process of determining if the email address is valid and exists, which includes checking the syntax of the email. If you do not validate the emails before sending any promotional or marketing emails, Once you’ve ensured your email list is clean, you can confidently use your polished email templates to engage with your audience..

Here are some of the ways of validating an email:

  • Use tools to check the syntax of the email addresses. Online email address validation tools assist individuals in checking the syntax and also verify if the email exists.
  • You can manually send a test message to the desired email address and see if it is delivered or not.

How to Write Email Validation Test Cases?

While writing email validation test cases, testers need to focus on a few details. Keep these key points in mind to create and execute tests for validating email addresses easily and quickly.

  • You will have to test for the correct email addresses as well as incorrect email addresses. Look out for the @ symbol and valid domains, such as .com, .org, .in, and other regional domains. Anything other than these domains should be rejected by the email field.
  • Ensure that the email format is right. contactus@abc.com should not be contact@us@.com.
  • Keep the foundational idea for testing in mind when validating an email; you are to check if the email exists and if you can successfully receive your emails.
  • Do not overlook negative test cases. See the response of the system when the email is invalid and the right notification message is shown.

For further reading of similar test case scenarios, check out our blogs on test cases for the registration page and test cases for API testing.

Look at this list of valid email ID examples you should aim to verify.

Valid Email ID Examples

Valid email addressesValidity reason
user@example.comFollows the standard format of “user@domain.com.”
user123@email.co.ukConsists of alphanumeric characters and a valid top-level domain (.co.uk).
john.doe@company.orgUses a period in the local part and a valid top-level domain (.org).
user_name1234@email-provider.netAlphanumeric characters underscores, and a hyphen are allowed in the local part. Valid top-level domain (.net).
info@sub.domain.comIncludes a subdomain (sub) in the domain part. Valid top-level domain (.com).
name@my-email-provider.xyzUses a hyphen in the domain part and has a valid top-level domain (.xyz).
user123@[192.168.1.1]Encloses the IP address within square brackets, which is a valid format for email addresses.
john.doe@email.travelUtilizes a period in the local part and has a valid top-level domain (.travel).
_______@domain.comUses an underscore for the entire local part, which is a valid name for an email.

Invalid Email ID Examples

Invalid email IDsInvalidity reasons
user@invalid-tld.123The top-level domain (.123) is not a valid TLD according to established standards.
user#domain.comMissing the “@” symbol, which is essential for separating the local part from the domain.
user#domain.conIncorrect domain name.
user&name@email-provider.netContains an invalid character (&) in the local part.
spaced user@domain.infoSpaces are not allowed in the email address, causing it to be invalid.
double..dots@email.orgConsecutive dots in the local part are not allowed, making the email address invalid.
@.comThe email address lacks a local part, resulting in an incomplete and invalid format.
user@domain with space.comSpaces are not allowed within the domain part of the email address.
user@domain..comConsecutive dots in the domain part are not allowed, making the email address invalid.

And because any example beyond theory is better for understanding. Below, we list down usable and working test cases for email validation.

Email Validation Test Cases

Validating emails consists of multiple parts, all of which are essential. The username part should work fine along with the domain name. Any mismatch and the entire email address is faulty. So, before you move on to running the test cases, let’s have a look at them.

Functional Email Validation Test Cases

  • Verify the correct email addresses in the standard format (user@domain.com).
  • Test if the email is case-insensitive.
  • Confirm that email addresses have valid top-level domains (e.g., .com, .net).
  • Validate that the system accepts special characters in the username of the email address.
  • Verify that the system ignores leading and trailing spaces in the email address.
  • Confirm that email addresses with subdomains are valid (e.g., user@sub.domain.com).
  • Test multiple valid email formats to ensure the system recognizes and accepts variations.

Test Scenarios for Sending Emails

After you have validated the email addresses, let’s send relevant company emails to them. Test for these scenarios for properly sending mails without any glitches:

Basic functionality

  • Verify that users can create a new email by clicking on the Compose or New Email button.
  • Enter the validated emails into the To field.
  • Test that validated email addresses can be added to the CC (Carbon Copy) and BCC (Blind Carbon Copy) fields.
  • Verify that attachments can be added to emails sent to validated email addresses.
  • Confirm that users can successfully send an email to a validated recipient.

Recipient handling

  • Confirm that validated email addresses appear in auto-suggestions as users type in the recipient fields.
  • Test the integration with the user’s contact list to easily add validated recipients from existing contacts.
  • Confirm that the system provides appropriate feedback for any attempt to send emails to invalid or non-validated email addresses.

Email tracking and notifications

  • Test the functionality to request and receive read receipts for sent emails.
  • Verify that sent emails are correctly updated in the user’s “Sent” folder or equivalent.
  • Verify that emails sent to invalid emails bounce back to the original email address with the proper error message.

Common Real-time Scenarios and Validation Points for Emails

Our goal with verifying the email field and validating email addresses is to keep the company email recipient list healthy and clean. Issues in both aspects lead to losing out leads and keeping invalid emails relevant for your business. Furthermore, a clean email list maintains a good sender reputation and a high deliverability level.

A routine rinsing of the email recipient helps to maintain the list of qualified leads, but it is far too lengthy a process. Let’s look at real-time email validation scenarios. It is the process of checking the validity of an email address in real-time using email validator tools. The goal is to ensure that the provided email address is accurate, properly formatted, and exists before further action, such as sending an email or saving it to a database.

Syntax Check

Verify that the entered email address follows the standard syntax, including the presence of the “@” symbol, a valid local part, a valid domain, and a valid top-level domain (TLD).

Domain Existence

Confirm that the domain of the email address exists and is registered. This involves checking DNS records to ensure the domain is legitimate.

MX Record Check

Check the Mail Exchange (MX) records of the domain to ensure it is configured to receive emails.

Disposable Email Detection

Identify and flag email addresses associated with known disposable or temporary email providers to prevent the use of such addresses.

Role-Based Email Detection

Detect and flag email addresses associated with roles (e.g., admin@company.com, support@domain.com) to encourage communication with individual users.

Prevent Invalid Submissions

Restrict users from proceeding with form submissions if the entered email address is determined to be invalid.

Domain-Specific Rules

Implement domain-specific validation rules to ensure that email addresses adhere to any additional requirements or restrictions imposed by the domain.

Conclusion

Marketers rely heavily on emails to acquire a reliable customer base and promote their products. Emails are still one of the highest driving factors that can make or break a business. And if you are looking to do the former, testing email fields on your website and ensuring to collect only valid emails is the way to go.

Follow the right test cases for email field verification and email validation, and you are good to perform all your email marketing tasks.

Frequently asked questions

How do you write an effective email to a QA?

When it comes to effectiveness, you have to be clear and concise. A transparent subject with an informative email body is the way to go. You can follow the template below:

Subject: Clear and Concise Bug Report

Email body:

Hi [QA Team],

I hope this email finds you well. I’ve identified a critical bug in [feature/module]. Please review the attached screenshot for details. Steps to reproduce:

[Step 1]

[Step 2]

[Step 3]

Expected Result: [Expected]

Actual Result: [Actual]

Your prompt attention to this matter is appreciated.

Best,

[Your Name]

How do you test emails in manual testing?

Follow these test cases for manual testing the emails:

  • Syntax Check: Verify standard email format (user@domain.com).
  • Domain Existence: Confirm the domain’s existence and registration.
  • MX Record Check: Validate Mail Exchange records for email deliverability.
  • Disposable Email Detection: Identify and block disposable email addresses.
  • Role-Based Detection: Flag role-based addresses (e.g., admin@company.com).
  • Spam Trap Detection: Check for associations with spam traps or blacklisted domains.
  • Real-Time Feedback: Provide instant feedback on entered email validity.

Prevent Invalid Submissions: Restrict form submissions with invalid email addresses for data integrity.

Test Cases for Address field
Test Cases For Address Field | How to Write (Samples)?
Test Cases for Mobile Application
Test Cases for Mobile Application & How to Use for Testing
Test Cases for Radio Button
Test Case For Radio Button & How to Write It?
imageimage
Subscribe to get all our latest blogs, updates delivered directly to your inbox.

RELATED BLOGS


Types of Testers: A Comprehensive Guide 
RAHUL PARWAL
AUTOMATION TESTING
Automated Test Oracles in Software Testing
KIRUTHIKA DEVARAJ
AUTOMATION TESTING
Accelq vs Provar | Which One You Should Choose?
TESTSIGMA ENGINEERING TEAM
AUTOMATION TESTING