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 6580839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:04:39+00:00 2026-05-25T16:04:39+00:00

I don’t think I understand testing as well a should. I have written a

  • 0

I don’t think I understand testing as well a should. I have written a lot of tests and gotten decent coverage but I cannot help feeling it has not been intuitive.

Let me explain: if I have a class the I am testing a method and it needs to be passed a big object of some sort, with all kinds of state. This object in turn contains other objects and their states that I know nothing of, how do I create mock or stub objects for this method and give it data that it can work with. It seems I have to create a big object with all kinds of internal sub object information to exercise my method.
I’m clearly confused!

  • 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-05-25T16:04:39+00:00Added an answer on May 25, 2026 at 4:04 pm

    The other answers here are pointing you to mocking frameworks, which you should definitely look at if you’re not already using (use Mockito!). However, this is almost certainly an instance of your tests telling you that you’ve got design problems. If you find yourself having to provide all kinds of unrelated information and mock objects just to make a test pass, then you’re

    1. trying to test too many pieces at once,
    2. writing a test that will be very difficult to read and understand when you’re done with it because it’s impossible to determine what the test is supposed to be focused on due to a low signal/noise ratio, and/or
    3. writing an extremely fragile test that will break on the slightest, unrelated change, incurring high maintenance costs and a “just make the test pass” mentality that doesn’t care what the test is supposed to be testing.

    These are all symptoms of a system not designed for testability, which almost universally equates to a system not designed for readability, meaning it’s not designed well.

    If you care about testing well, embrace test-first thinking and TDD. I highly recommend a couple of books on the subject: “xUnit Test Patterns”, which I’ve read and reviewed, and “Growing Object-Oriented Software, Guided by Tests”, which I’m almost finished reading.

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

Sidebar

Related Questions

Don't really know how to formulate the title, but it should be pretty obvious
Don't think that I'm mad, I understand how php works! That being said. I
Don't think my virtualhost is working correctly. This is what I have inside of
Don't ask why but I have the requirement to draw a border around certain
DON'T ASK WHY but... I have a regex that needs to be case insensitive
Don't know why but I can't find a solution to this. I have 3
I don't know if it's actually possible to do, but I have a text
Don't you hate it when you have class Foobar { public: Something& getSomething(int index)
Don't know how to google for such, but is there a way to query
I don't understand where the extra bits are coming from in this article about

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.