开发者

Integration Testing Emails sent from an MVC3 .Net application

开发者 https://www.devze.com 2023-02-11 02:03 出处:网络
What is a good way to produce reliable integration test results for a mail service in a development environment for a .NET MVC3 web application?The email service is already isolated behind an interfac

What is a good way to produce reliable integration test results for a mail service in a development environment for a .NET MVC3 web application? The email service is already isolated behind an interface and the unit tests are written for it, but I was curious if there are there any good, gene开发者_C百科ral tools or strategies that are available to make it easy other than spamming some email address and having some full-blown smtp server setup somewhere.

Things that should be easy to test should be:

- given a correct setup, can an email be sent

- given an incorrect setup, can we detect it and get that status back.


A good tip if you're using your web.config to store you SMTP server settings is that you can use the following configuration to dump all emails sent into a directory on your development environment.

<system.net>
  <mailSettings>
    <smtp deliveryMethod="SpecifiedPickupDirectory">
      <specifiedPickupDirectory pickupDirectoryLocation="c:\email"/>
      <network host="localhost"/>
    </smtp>
  </mailSettings>
</system.net>


You can use special version of SMTP servers made for testing, look at:

Testing Mail Functionality with Neptune

Antix Developer SMTP server

0

精彩评论

暂无评论...
验证码 换一张
取 消