List of mock valid/invalid Email Addresses for Uni

2019-03-11 17:50发布

问题:

Does anyone know of a list of email addresses (which don’t need to be real) I can use for an email validation assembly for a unit test?

I’ve been looking for such a list and can’t seem to find one. I’m not looking for real addresses, just ones that fit, and the more things I can throw at the test the better. I’ve got 10 right now, but if there is a list, it would give me a more thorough test.

回答1:

I believe you were looking for something like this:

List of Valid and Invalid Email Addresses



回答2:

Check the tests of the Apache Commons EmailValidator class:

  • EmailTest,
  • EmailValidatorTest.

The EmailValidatorTest in the Hibernate Validator also contains some address.



回答3:

I like to use the set in this page on email validating regexes because the addresses contain what they're testing inside the email address.



回答4:

Here is a set of test emails that Dominic Sayers uses to test his isEmail validator:

http://code.iamcal.com/php/rfc822/tests/

For more on isEmail:

http://isemail.info/about