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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:51:49+00:00 2026-05-16T07:51:49+00:00

Two questions about unit tests. I’ve been writing unit tests for a while, however

  • 0

Two questions about unit tests.

  1. I’ve been writing unit tests for
    a while, however they’re usually to
    test classes I already had written.
    Recently I read an article
    (mind you an old article) that says
    you should write unit tests before
    you begin writing your code.

    Does anyone actually follow this
    methodology? It seems like a good
    idea on paper, but in practice is
    it?

  2. Should you write unit tests to see how your method handles bad/malicious input? Obviously you would want to write tests against functions which are specifically meant to handle “user” input to see how it handles bad/malicious input, but what about functions which should never have this type of input passed to them? At what point do you draw the line?
  • 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-16T07:51:50+00:00Added an answer on May 16, 2026 at 7:51 am

    The methodology of writing unit tests before the classes is called Test-Driven Development (TDD) and was popularized by Kent Beck in the early 2000s. The idea is that you write a test that describes the functionality that you need. Initially, this test will fail. As you write your class, the test passes. You refactor your test to add more desired functionality, then refactor the class to make this new test pass. Your class has met its goals as soon as the tests pass. Of course, this scales up beyond classes as well.

    As to what types of tests to write, it depends on if you are testing a public API or a private API. Public APIs should have more extensive tests written to ensure that input is well formed, especially if you don’t fully trust the users of your API. Private APIs (methods that are only called by your code) can probably get away without these tests – I would suspect that you can trust your own development team to not pass in bad data to them.

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

Sidebar

Ask A Question

Stats

  • Questions 515k
  • Answers 515k
  • 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
  • Editorial Team
    Editorial Team added an answer Try: set(gca, 'Layer','top') according to the documentation page: Layer {bottom}… May 16, 2026 at 6:37 pm
  • Editorial Team
    Editorial Team added an answer I got it working but it doesn't feel very clean… May 16, 2026 at 6:37 pm
  • Editorial Team
    Editorial Team added an answer class TagParser(HTMLParser): def __init__(self, url, tag): HTMLParser.__init__(self) self.tag = tag… May 16, 2026 at 6:37 pm

Trending Tags

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

Top Members

Related Questions

Some DO facts: two developers in a team we write unit tests (auto run
Could you please explain the following two questions about Visual Web Developer 2008? 1)
The first real software company that I worked at was all about the unit
I decided to add unit tests to my project and continue development in a
Given two orthogonal unit vectors, A and B, and two different orthogonal unit vectors
Two questions pertaining to a FTP Batch upload script I'm working on. 1) My
With these two questions as background ( first and second ), I got curious
Several HOW TO questions about simple and multidimensional arrays: 1) How to search in
Reading through the existing unit testing related threads here on Stack Overflow, I couldn't
In my Asp.net MVC app, I have two methods on a controller, one for

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.