Filipin.eu

Željko Filipin's blog.
Home Blog Tags License

View on GitHub
7 February 2007

Testing E-mail: The Code

by Željko Filipin

tags: code · ruby

Estimated reading time is 1 minute.

Lately I have been testing e-mail functionality of web application. This is the fifth post about that experience. Last week I wrote about lessons learned.

I have written a little framework that helps me with testing e-mail.

To use it, you will have to install Ruby, Tmail and SMTP server.

Then download mail.zip (2,20 KB) and extract it. No installation required. There are even some unit tests (unit_tests.rb) and example code (usage.rb).

Send mail.

SendMail.new(
  "user@domain",
  "application@domain",
  "title",
  "body").send

Check if application sent mail that you have expected.

Mail.received?(
  [Mail.new(
    "application@domain",
    "user@domain",
    "title")])

For now, mail that is sent can only contain from, to, subject and body. While receiving, I only check from, to and subject

This is code that I am really using every day.

Please understand that I am a tester, not a developer, and I know that this code could be better. Feel free to improve it. Post bug reports and your comments here.

Feedback

Thank you for reading. If you want to stay in touch please use the feed or send me an email.