smtp4dev

Capturing emails in Acceptance tests with Specflow

Pretty much every web application out there nowadays needs to send emails, whether it be for registration, password reset or some other bespoke functionality. When you’re working in your own dev environment and building out features, tools like smtp4dev work great for capturing emails sent to localhost; to use, simply add the following to web.config

<system.net>
  <mailSettings>
    <smtp deliveryMethod="Network">
      <network host="localhost" port="25" defaultCredentials="true" />
    </smtp>
  </mailSettings>
</system.net>

start smtp4dev.exe

Screenshot 2014-10-20 22.28.02

and you can start capturing emails sent whilst developing. You can use web config transforms or slow cheetah to replace the mail settings for different build configurations too. But what about acceptance tests; how do you handle emails sent during acceptance test runs?

Read more...