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

  • Home
  • SEARCH
  • 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 48731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:19:33+00:00 2026-05-10T16:19:33+00:00

A while ago I read the Mocks Aren’t Stubs article by Martin Fowler and

  • 0

A while ago I read the Mocks Aren’t Stubs article by Martin Fowler and I must admit I’m a bit scared of external dependencies with regards to added complexity so I would like to ask:

What is the best method to use when unit testing?

Is it better to always use a mock framework to automatically mock the dependencies of the method being tested, or would you prefer to use simpler mechanisms like for instance test stubs?

  • 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. 2026-05-10T16:19:34+00:00Added an answer on May 10, 2026 at 4:19 pm

    As the mantra goes ‘Go with the simplest thing that can possibly work.’

    1. If fake classes can get the job done, go with them.
    2. If you need an interface with multiple methods to be mocked, go with a mock framework.

    Avoid using mocks always because they make tests brittle. Your tests now have intricate knowledge of the methods called by the implementation, if the mocked interface or your implementation changes… your tests break. This is bad coz you’ll spend additional time getting your tests to run instead of just getting your SUT to run. Tests should not be inappropriately intimate with the implementation.
    So use your best judgment.. I prefer mocks when it’ll help save me writing-updating a fake class with n>>3 methods.

    Update Epilogue/Deliberation:
    (Thanks to Toran Billups for example of a mockist test. See below)
    Hi Doug, Well I think we’ve transcended into another holy war – Classic TDDers vs Mockist TDDers. I think I’m belong to the former.

    • If I am on test#101 Test_ExportProductList and I find I need to add a new param to IProductService.GetProducts(). I do that get this test green. I use a refactoring tool to update all other references. Now I find all the mockist tests calling this member now blow up. Then I have to go back and update all these tests – a waste of time. Why did ShouldPopulateProductsListOnViewLoadWhenPostBackIsFalse fail? Was it because the code is broken? Rather the tests are broken. I favor the one test failure = 1 place to fix. Mocking freq goes against that. Would stubs be better? If it I had a fake_class.GetProducts().. sure One place to change instead of shotgun surgery over multiple Expect calls. In the end it’s a matter of style.. if you had a common utility method MockHelper.SetupExpectForGetProducts() – that’d also suffice.. but you’ll see that this is uncommon.
    • If you place a white strip on the test name, the test is hard to read. Lot of plumbing code for the mock framework hides the actual test being performed.
    • requires you to learn this particular flavor of a mocking framework
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 73k
  • Answers 73k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer I find it helpful to launch the offline MSDN library… May 11, 2026 at 1:59 pm
  • added an answer A 'Driver class' is often just the class that contains… May 11, 2026 at 1:59 pm
  • added an answer Operating systems have to manage the sizes of CPU caches… May 11, 2026 at 1:58 pm

Related Questions

A while ago I read the Mocks Aren't Stubs article by Martin Fowler and
A good while ago, I read an article by the creator of viemu ,
A while ago I had a query that I ran quite a lot for
A while ago I was trying to figure out a way of doing this
A little while ago I managed to get Visual Studio 2008 (C++) into a
A while ago, I started on a project where I designed a html-esque XML
A while ago, I had a discussion with a colleague about how to insert
I recently read a question on here about static and dynamic linking, which reminded

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.