1
Today I have a system, which sends several emails.
- Many settings and upload rules.
- I need to add about 50 new rules, new emails
- Time formats with attached file, images and other "cositas" more.
Like this one today, I use an e-mail server to authenticate and send the emails.
But I need to do some integration tests to validate these rules!
- How would you do that?
- Sign up script 50 new users?
- How to validate the content of this email, at least some parts?
Using Mock? but then how do I test? the criterias, the business rules embedded in all this scenario
- Scenario description is complex.
- I use Sprig 4.2
- Use Hibernate, criteria
- Junit
- testNG
- Themeleaf 3 to build the e-mail
- The classes are many, Describe the main
- Definepropertie (defines e-mail properties)
- Classes that define persistence layer (@Service, @Repository)
- Quartz classes that perform and schedule email tasks as object states change
- Classes that assemble the emails
- Classes that trigger emails
- Spring Component Objects that integrate Quartz and link the services of the classes that send the email.
Suggestions, because the complexity of the scenario is quite large
Suggestion to validate email content,
Expression Regular
– R.Santos
If you use
beanvalidation
has the annotation@Email
– Roknauta
I don’t think you’ll understand, Regular Expression ok, how do you capture such email to apply validation? " beanvalidation has the @Email" annotation I meant by that?
– Marcelo Ferreira
Marcelo I think the question is very broad... There are multiple ways to do this kind of thing. As you said yourself, it is possible to mock the authentication and email sending service (for example, by checking whether the contents generated in memory for the final email match the mocked input parameters for each "profile" that would activate a rule). You can use a service like Mailtrap., lift a Fake SMTP server (e. g., Fakesmtp) or even a real SMTP server.
– Anthony Accioly
@Anthony liked that, Fakesmtp ever used that? has any suggestions for me to narrow the scope of the question?
– Marcelo Ferreira
No, but I’ve used the Dumbster. that follows the same idea. Also I had to implement my own fake SMTP server in a project for acceptance testing (not recommend, pay Mailtrap.io :D). I would tell you to play a little with the options and read articles like that. As you go understand the techniques the questions will become more specific. "Integration test for emails" is very broad.
– Anthony Accioly
Describe a little more about your architecture, which classes represent email addresses, email messages, email users, filtering rules, routing rules, which class sends the email, etc. Otherwise, Any response will either be too vague and shallow to be useful or it will depend on a good deal of speculation. I tried to write an answer, and I came to the conclusion that it just doesn’t because your question is too wide.
– Victor Stafusa
I tried to put a summary of my scenario, but it is still much more complex than I described, but what you have now, already illustrates the size of the complexity I have
– Marcelo Ferreira