2

I have a test that reads Auth Code from mailbox and uses it to log in. I use Gmail API for that.

I would like to have several such tests that will run in parallel.

However, I don't know, how to distinguish emails from each other, because the only thing that is different about 2 emails is this Auth Code.

So, race condition looks like this:

  1. test-1 sends an email at 00:00:00
  2. test-2 sends an email at 00:00:01
  3. it takes 3 seconds for the email-1 to arrive => 00:00:03,
  4. it takes only 1 second for the email-2 to arrive => 00:00:02
  5. test-1 reads the first unread matching email, and it is an email-2 Result: Auth code is wrong.

So, my question here is: could you please think of any possible solution to avoid such a race condition and identify the email?

Thank you!

  • Didn't you consider using different emails for different threads? – Alexey R. Aug 18 at 18:33
  • Thank you, good idea – Ekaterina Korneeva Aug 19 at 11:19
1

Why don't you use different e-mail accoouns for this (of course if you are not going to test the case when user try to login two times and mix codes/use proper codes from two messages e.g. on 2 devices)?

| improve this answer | |
  • 2
    How about using Gmails wildcard feature "myname+randomWildcard@gmail.com" and then distinguish based on "randomWildcard"? – Paul Vincent Beigang Aug 19 at 5:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.