Open In App

How to Write Email Validation Test Cases?

Last Updated : 19 Apr, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Email validation is a critical part of any web application. It ensures that users are entering valid email addresses, which can be used for communication and authentication. Writing email validation test cases can be tricky, as there are a lot of different things to consider. Email validation test cases are an important part of any email testing strategy. By taking the time to write out a few key test cases, you can ensure that your email system is functioning correctly and that your users are receiving the emails they expect. The article focuses on discussing email validation test cases.

What is Email Validation?

Email validation is the process of determining whether an email address is valid. This can be done by checking the syntax of the email address, as well as verifying that the email address exists and is able to receive messages. Email validation is important in order to ensure that messages are sent to valid email addresses. Invalid email addresses can result in messages being undeliverable, or worse, being delivered to the wrong person. There are a few different methods that can be used to validate an email address. 

  • One common method is to use an online Email Address Validation Tool. This tool will check the syntax of an email address and also verify that the email address exists and is able to receive messages.
  • Another common method for validating an email address is to send a test message to the address. This can be done using a service such as Mailinator, Mailtrap, etc which provides temporary inboxes for testing purposes. Simply send a test message to the desired email address and then check whether it arrives in the inbox. Email validation is an important part of ensuring successful communication via email. By taking the time to validate email addresses, you can help ensure that your messages are always delivered as intended.

Email Validation Test Cases

When writing email validation test cases, there are a few key things to keep in mind. 

  1. Test for the correct format of an email address. This includes testing for the presence of an @ symbol and a .com, .org, or other valid domain.
  2. Test that the email address is correctly formatted for the specific application you’re testing. This might include ensuring that there are no spaces in the address, or that certain characters are not used.
  3. Test that the email address is actually valid and can receive mail. This can be done by sending a test email to the address and checking for delivery confirmation.
  4. Test what happens when an invalid email address is entered into the system. This might include checking for error messages or other indicators that the address is not valid.
Features to be Tested Test Cases
Valid email format
  • name@domain.com
  • A valid email with a sub-domain: name@sub.domain.com
  • A valid email with IP address domain: name@123.123.123.123
  • A valid email with the quoted name: “name”@domain.com
  • A valid email with a local part longer than 64 characters: verylongname@domain.com
  • A valid email with a domain part longer than 255 characters: name@verylongdomainpart.com
  • A valid email with quoted local part: “verylongname”@domain.com
  • A valid email with an alphanumeric domain: name@domain.com
 Invalid email format
  • name@domain
  • name@domain.
  • name@domain.c
  • name@-domain.com
  • name@_domain.com
  • name@domain-.com
  • name@domain.com_
  • name@.domain.com
  • name@domain..com
  • An invalid email with multiple @ symbols: name@domain@domain.com
  • An invalid email with multiple. symbols: name@domain.domain.com
  • An invalid email with spaces: name @ domain.com
  • An invalid email with the invalid quoted name: “”name””@domain.com
  • An invalid email with missing quoted name: “name”@domain@com
  • An invalid email with unbalanced quotes: “name”@domain”com. 
  • An invalid email with a local part longer than 65 characters: verylongname@domain.com_
  • An invalid email with a domain part longer than 256 characters: name@verylongdomainpart.com_
  • An invalid email with quoted local part longer than 64 characters: “verylongname”@domain.com_. 
  • An invalid email with an invalid IP address domain: name@123.123.123.1234
  • An invalid email with only a numeric domain: name@123
  • An invalid email with missing @ symbol: namedomain.com
  • An invalid email with an extra @ symbol: name@domain@com
  • An invalid email with missing . in the domain: name@domaincom
  • An invalid email with consecutive. in the domain: name@domain..com
  • An invalid email with leading . in the domain: name@.domain.com
  • An invalid email with trailing . in the domain: name@domain.com.
  • An invalid email with leading – in the domain: name@-domain.com
  • An invalid email with trailing – in the domain: name@domain-.com
  • Invalid email with leading _ in domain: name@_domain.com
  • Invalid email with trailing _ in domain: name@domain.com_
  • An invalid email with leading – in local part: name@domain.-com
  • An invalid email with trailing – in local part: name@domain.com-
  • An invalid email with leading _ in the local part: name@domain._com
  • Invalid email with trailing _ in local part: name@domain.com_
  • An invalid email with leading – in quoted local part: “name”-@domain.com
  • An invalid email with trailing – in quoted local part: “name”@domain.com-
  • Invalid email with leading _ in quoted local part: “_name”@domain.com
  • An invalid email with trailing _ in quoted local part: “name_”@domain.com
  • An invalid email with a missing domain: name@
  • An invalid email with a missing local part: @domain.com
  • An invalid email with consecutive .. in the domain: name@domain..com.
Local part quoted 
  • Email address with a period in quoted local part: “name.name”@domain.com
  • Email address with 2 periods in quoted local part: “name..name”@domain.com
  • Email address with a period in quoted local part and leading period: “.name.name”@domain.com
  • Email address with a period in quoted local part and trailing period: “name.name.”@domain.com
  • Email address with a period in quoted local part and 2 consecutive periods: “name..name”@domain.com
  • Email address with a period in quoted local part and 2 consecutive periods and leading period: “.name..name”@domain.com
  • Email address with a period in quoted local part and 2 consecutive periods and trailing period: “name..name.”@domain.com
  • Email address with a period in the domain: name@domain.com.
  • Email address with 2 periods in the domain: name@domain..com
  • Email address with a period in the domain and leading period: name@.domain.com
  • Email address with a period in domain and trailing period: name@domain.com.
  • Email address with 2 periods in the domain and leading period: name@.domain..com
  • Email address with 2 periods in domain and trailing period: name@domain..com.
  • Email address with 2 periods in the domain and 2 consecutive periods: name@domain..com..
  • Email address with 2 periods in the domain and 2 consecutive periods and leading period: name@.domain..com..
  • Email address with 2 periods in the domain and 2 consecutive periods and trailing period: name@domain..com..
  • Email address with 2 periods in the domain and 2 consecutive periods and leading and trailing period: name@.domain..com..
  • Email address with a period in local part: name.name@domain.com
  • Email address with 2 periods in local part: name..name@domain.com
  • Email address with a period in local part and leading period: .name.name@domain.com
  • Email address with a period in the local part and trailing period: name.name.@domain.com
  • Email address with 2 periods in local part and leading period: .name..name@domain.com
  • Email address with 2 periods in local part and trailing period: name..name.@domain.com
  • Email address with 2 periods in the local part and 2 consecutive periods: name..name@domain.com
  • Email address with 2 periods in local part and 2 consecutive periods and leading period: .name..name@domain.com
  • Email address with 2 periods in local part and 2 consecutive periods and trailing period: name..name.@domain.com
  • Email address with 2 periods in local part and 2 consecutive periods and leading and trailing period: .name..name.@domain.com
  • Email address with quoted local part and period in quoted local part: “name.name”@domain.com
  • Email address with quoted local part and 2 periods in quoted local part: “name..name”@domain.com
  • Email address with quoted local part and period in quoted local part and leading period: “.name.name”@domain.com
  • Email address with quoted local part and period in quoted local part and trailing period: “name.name.”@domain.com
  • Email address with quoted local part and 2 periods in quoted local part and leading period: “.name..name”@domain.com
  • Email address with quoted local part and 2 periods in quoted local part and trailing period: “name..name.”@domain.com
  • Email address with quoted local part and 2 periods in quoted local part and 2 consecutive periods: “name..name”@domain.com
  • Email address with quoted local part and 2 periods in quoted local part and 2 consecutive periods and leading period:”.name..name”@domain.com
    Email address with quoted local part and 2 periods in quoted local part and 2 consecutive periods and trailing period: “name..name.”@domain.com
  • Email address with quoted local part and 2 periods in quoted local part and 2 consecutive periods and leading and trailing period: “.name..name.”@domain.com
  • Email address with quoted local part and period in the domain: “name.name”@domain.com
  • Email address with quoted local part and 2 periods in the domain: “name..name”@domain.com
  • Email address with quoted local part and period in the domain and leading period: “.name.name”@domain.com
  • Email address with quoted local part and period in domain and trailing period: “name.name.”@domain.com
  • Email address with quoted local part and 2 periods in the domain and leading period: “.name..name”@domain.com
  • Email address with quoted local part and 2 periods in domain and trailing period: “name..name.”@domain.com
  • 102. Email address with quoted local part and 2 periods in the domain and 2 consecutive periods: “name..name”@domain.com
  • 103. Email address with quoted local part and 2 periods in the domain and 2 consecutive periods and leading period: “.name..name”@domain.com
  • 104. Email address with quoted local part and 2 periods in the domain and 2 consecutive periods and trailing period: “name..name.”@domain.com
    105. Email address with quoted local part and 2 periods in the domain and 2 consecutive periods and leading and trailing period: “.name..name.”@domain.com
  • Email address with local part quoted and period in quoted local part: “name.name”@domain.com
  • Email address with local part quoted and 2 periods in quoted local part: “name..name”@domain.com
  • Email address with local part quoted and period in quoted local part and leading period: “.name.name”@domain.com
  • Email address with local part quoted and period in quoted local part and trailing period: “name.name.”@domain.com
  • Email address with local part quoted and 2 periods in quoted local part and leading period: “.name..name”@domain.com
  • Email address with local part quoted and 2 periods in quoted local part and trailing period: “name..name.”@domain.com
  • Email address with local part quoted and 2 periods in quoted local part and 2 consecutive periods: “name..name”@domain.com
  • Email address with local part quoted and 2 periods in quoted local part and 2 consecutive periods and leading period: “.name..name”@domain.com
  • Email address with local part quoted and 2 periods in quoted local part and 2 consecutive periods and trailing period: “name..name.”@domain.com
  • Email address with local part quoted and 2 periods in quoted local part and 2 consecutive periods and leading and trailing period: “.name..name.”@domain.com
  • Email address with local part quoted and period in the domain: “name.name”@domain.com
  • Email address with local part quoted and 2 periods in the domain: “name..name”@domain.com
  • Email address with local part quoted and period in the domain and leading period: “.name.name”@domain.com
  • Email address with local part quoted and period in the domain and trailing period: “name.name.”@domain.com

How to Write Email Validation Test Cases?

Email validation is a process of ensuring that an email address entered by a user is valid and exists. There are many ways to validate an email address, but the most common and effective method is to use an email validator

  • An email validator will check the syntax of an email address and check if the domain name exists. 
  • It will also verify whether the email account can receive messages. 
  • It could be the essence of the email marketing

Email validation is an important part of any application that requires users to input their email addresses. It helps to ensure that users enter valid and active email addresses, which reduces the chances of bounced messages and improves communication between businesses and their customers. Test cases for email validation should cover both invalid and valid email addresses. For invalid email addresses, test cases should check for common mistakes such as typos in the domain name, incorrect characters in the username, or missing @ sign. For valid email addresses, test cases should check that the Email Validator returns true when given a real-world example of a valid email address.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads