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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:11:07+00:00 2026-05-10T18:11:07+00:00

What Makes a Good Unit Test? says that a test should test only one

  • 0

What Makes a Good Unit Test? says that a test should test only one thing. What is the benefit from that?

Wouldn’t it be better to write a bit bigger tests that test bigger block of code? Investigating a test failure is anyway hard and I don’t see help to it from smaller tests.

Edit: The word unit is not that important. Let’s say I consider the unit a bit bigger. That is not the issue here. The real question is why make a test or more for all methods as few tests that cover many methods is simpler.

An example: A list class. Why should I make separate tests for addition and removal? A one test that first adds then removes sounds simpler.

  • 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-10T18:11:08+00:00Added an answer on May 10, 2026 at 6:11 pm

    I’m going to go out on a limb here, and say that the ‘only test one thing’ advice isn’t as actually helpful as it’s sometimes made out to be.

    Sometimes tests take a certain amount of setting up. Sometimes they may even take a certain amount of time to set up (in the real world). Often you can test two actions in one go.

    Pro: only have all that setup occur once. Your tests after the first action will prove that the world is how you expect it to be before the second action. Less code, faster test run.

    Con: if either action fails, you’ll get the same result: the same test will fail. You’ll have less information about where the problem is than if you only had a single action in each of two tests.

    In reality, I find that the ‘con’ here isn’t much of a problem. The stack trace often narrows things down very quickly, and I’m going to make sure I fix the code anyway.

    A slightly different ‘con’ here is that it breaks the ‘write a new test, make it pass, refactor’ cycle. I view that as an ideal cycle, but one which doesn’t always mirror reality. Sometimes it’s simply more pragmatic to add an extra action and check (or possibly just another check to an existing action) in a current test than to create a new one.

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

Sidebar

Ask A Question

Stats

  • Questions 70k
  • Answers 70k
  • 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've done this before using the standard SQL sorting syntax.… May 11, 2026 at 1:06 pm
  • added an answer Set a flag when a MouseDown event occurs, storing the… May 11, 2026 at 1:06 pm
  • added an answer The best, well-supported way to access the WinHTTP 5.1 APIs… May 11, 2026 at 1:06 pm

Related Questions

Kindly point towards theory/material to read for understanding colors and what makes a good
What is a good regular expression that can validate a text string to make
What is the cheap and good way to make a serial (RS232) programmer for
What makes a language a scripting language? I've heard some people say "when it
I know the question about measuring developer performance has been asked to death, but
I'm working with a small (4 person) development team on a C# project. I've
I see lots of TDD practitioners following this cycle: 1) Write your test as
I have written some code that makes use of an open source library to

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.