End-to-End (e2e) testing can be a laborious and extremely repetitive task. While these can (and should) be automated there are use cases as a tester that are more effort than they are worth to automate. Or in the case of a bug need to be run through manually to reproduce and triage.

If a workflow or e2e test requires creating a new user account or performing an action to a user only once (perhaps deleting them) there needs to be efficient ways to create and manage your identities without creating new email accounts or aliases every time. Fortunately Gmail has a couple of handy features up their sleeve for parsing your email address which work to your benefit as a tester.

The DOT Syntax

This is less flexible but it is sort of cool to know. Gmail ignores the period character in email addresses. This means I could sign up to Gmail as [email protected] but I could pass that onto others as scott.cab.[email protected], or scottcab.[email protected] or even s.c.o.t.t.c.a.b.r.u.l.e.[email protected] and they would all be sent back to my base address! This is nice to know but a little limited for testing purposes, what else can we use?

The PLUS Syntax

In addition to ignoring the period character Gmail also lets you create aliases by appending a + and some other string between your email name and the @ symbol. Following my example from above I could take [email protected] and change it to scottcabrules+1@gmail.com, scottcabrules+trustme@gmail.com or scottcabrules+yougettheidea@gmail.com and they would all be routed back to my base address. Awesome!

Because of the flexible nature of this naming scheme we now have near infinite possibilities for creating "multiple" email addresses (for the purposes of your application) but managing them through the one inbox with the one login.

Here are some tips I have used to manage multiple accounts at once for a given application:

Create a base email address specifically for dev testing

I currently use nottellingyou.dev@gmail.com. Appending the .dev means I should never accidentally use the wrong address to sign up for things. (Ironically as you now know I could remove the period and it would still work).

Create email aliases based on user role

This is just a nice to have if you need multiple users in your app, you can create nottellingyou.dev+admin@gmail.com or nottellingyou.dev+user@gmail.com.

Create email addresses based on time stamp

If you have to create a tonne of one off emails that you will never need again to test a flow I like to use the YYYmmdd_n format where n is the number of attempts for the day. For example nottellingyou+20200101_1@gmail.com for the first attempt and nottellingyou+20200101_2@gmail.com for the second attempt on January 1st 2020. These are easy to throw away and guaranteed to be unique, if you subscribe to the notion that time is a linear construct, but that discussion really is beyond the scope of this article...

Bonus Round

If you use this base email address for multiple apps or regular user accounts then it can be really tricky to keep track of all the emails coming in and what user they are for, this is doubly true if you are testing sign up flows that require email verification. To make life easier for yourself you can create labels for these emails then go to Settings -> Filters and blocked addresses and create a new filter. Depending on how granular you want to make these you can do it per app per user or just per user. Tell the filter to skip your inbox (archiving it straight away) and applying the appropriate label. Now it becomes very obvious which user has received new emails without needing to constantly check the "to" field.

Source: https://gmail.googleblog.com/2008/03/2-hidden-ways-to-get-more-from-your.html