Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8399787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:23:56+00:00 2026-06-09T21:23:56+00:00

Assuming an email implementation as simple as the accepted answer on this post ,

  • 0

Assuming an email implementation as simple as the accepted answer on this post, what can be the best way to write a unit test for the implementation? (I do not want to shoot emails to a valid recipient as part of testing the implementation)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T21:23:58+00:00Added an answer on June 9, 2026 at 9:23 pm

    First, make the part responsible for sending / receiving pluggable. Just make sure you can switch the class / function / object responsible for connecting / sending / receiving messages to / from the server.

    Second, make this part act as real thing. Make sure this class / function / object will fake original class’s / function’s / object’s behaviour as close as possible (take the same parameters, throw the same errors).

    Third, fake different behaviours of this part during tests. Different behaviours of this class in different tests may include:

    • correct sending,
    • delayed sending,
    • connection timed out,
    • successful receiving,

    and, depending on what your module really does (and how flexible it is, eg. if it can be used by someone else for coding), you can also include these behaviours:

    • error when incorrect parameters were passed,
    • wide range of other exceptions found here: http://docs.python.org/library/smtplib.html

    It really largely depends on what your module does. You need to test, if it does these things properly. Do not test smtplib module, as it is already covered with tests. Do not test things irrelevant to your module – just things it does. It is possible, that some parts of your modules are untestable – in that case you have two options: change them to be testable, or leave them as they are (it is sometimes the most reasonable option for various reasons).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assuming that parsing the equation would not be a problem, how can I make
Assuming i have a post model with created_at, title, and id. How can i
Assuming a collection like this: People { name: John Doe, email: John Doe <john@doe.com>,
Is there any way I can click on an email address on a website
Assuming this is my table: email | col1 | col2 ------+-------+------ a@a | 1
Assuming that I have this: enum { A = 0x2E, B = 0x23, C
Assuming: std::string ToShow,NumStr; The following displays This is 19 ch00: ToShow = This is
I have following table CREATE TABLE User ( email sysname NOT NULL, sign varbinary(256)
I noticed that I can do a Model.find in a number of ways (assuming
I have the following record definition: -record(contact, {name, email}) Assuming that I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.