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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T13:27:18+00:00 2026-05-10T13:27:18+00:00

I saw many questions asking ‘how’ to unit test in a specific language, but

  • 0

I saw many questions asking ‘how’ to unit test in a specific language, but no question asking ‘what’, ‘why’, and ‘when’.

  • What is it?
  • What does it do for me?
  • Why should I use it?
  • When should I use it (also when not)?
  • What are some common pitfalls and misconceptions
  • 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-10T13:27:19+00:00Added an answer on May 10, 2026 at 1:27 pm

    Unit testing is, roughly speaking, testing bits of your code in isolation with test code. The immediate advantages that come to mind are:

    • Running the tests becomes automate-able and repeatable
    • You can test at a much more granular level than point-and-click testing via a GUI

    Note that if your test code writes to a file, opens a database connection or does something over the network, it’s more appropriately categorized as an integration test. Integration tests are a good thing, but should not be confused with unit tests. Unit test code should be short, sweet and quick to execute.

    Another way to look at unit testing is that you write the tests first. This is known as Test-Driven Development (TDD for short). TDD brings additional advantages:

    • You don’t write speculative ‘I might need this in the future’ code — just enough to make the tests pass
    • The code you’ve written is always covered by tests
    • By writing the test first, you’re forced into thinking about how you want to call the code, which usually improves the design of the code in the long run.

    If you’re not doing unit testing now, I recommend you get started on it. Get a good book, practically any xUnit-book will do because the concepts are very much transferable between them.

    Sometimes writing unit tests can be painful. When it gets that way, try to find someone to help you, and resist the temptation to ‘just write the damn code’. Unit testing is a lot like washing the dishes. It’s not always pleasant, but it keeps your metaphorical kitchen clean, and you really want it to be clean. 🙂


    Edit: One misconception comes to mind, although I’m not sure if it’s so common. I’ve heard a project manager say that unit tests made the team write all the code twice. If it looks and feels that way, well, you’re doing it wrong. Not only does writing the tests usually speed up development, but it also gives you a convenient ‘now I’m done’ indicator that you wouldn’t have otherwise.

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

Sidebar

Related Questions

this is quite frustrating, I saw many questions around this topic, but strangely enough
I saw this related question about publishing toolchain but I know many people did
I saw many similar questions here but their answers don't work for me by
I have looked through as many previous questions as possible but never saw a
Saw many questions similar but still not able to find the clue. My new
I saw many questions about this, and tried to solve the problem, but after
I saw many questions raised for the problem with _id.But my problem is with
Saw this questions asked many times. But couldn't find a reasonable answer. What is
I saw that there are many questions liek this but I didn't find any
I saw many threads with this tittle, but no one really speak about reuse

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.