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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:28:11+00:00 2026-05-21T04:28:11+00:00

In TDD development, the first thing you typically do is to create your interface

  • 0

In TDD development, the first thing you typically do is to create your interface and then begin writing your unit tests against that interface. As you progress through the TDD process you would end-up creating a class that implements the interface and then at some point your unit test would pass.

Now my question is about the private and protected methods that I might have to write in my class in support of the methods/properties exposed by the interface:

  • Should the private methods in the class have their own unit tests?

  • Should the protected methods in the class have their own unit tests?

My thoughts:

  • Especially because I am coding to interfaces, I shouldn’t worry about protected/private methods as they are black boxes.

  • Because I am using interfaces, I am writing unit tests to validate that the contract defined is properly implemented by the different classes implementing the interface, so again I shouldnt worry about the private/protected methods and they should be exercised via unit tests that call the methods/properties defined by the interface.

  • If my code-coverage does not show that the protected/private methods are being hit, then I don’t have the right unit-tests or I have code thats not being used and should be removed.

  • 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-21T04:28:11+00:00Added an answer on May 21, 2026 at 4:28 am

    No, I don’t think of testing private or protected methods. The private and protected methods of a class aren’t part of the public interface, so they don’t expose public behavior. Generally these methods are created by refactorings you apply after you’ve made your test turn green.

    So these private methods are tested implicitly by the tests that assert the behavior of your public interface.

    On a more philosophical note, remember that you’re testing behavior, not methods. So if you think of the set of things that the class under test can do, as long as you can test and assert that the class behaves as expected, whether there are private (and protected) methods that are used internally by the class to implement that behavior is irrelevant. Those methods are implementation details of the public behavior.

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

Sidebar

Related Questions

i'm starting the TDD development attitude and am writting unit-tests for my django application.
In TDD, every body talks about creation of unit tests and how development is
What is test-first development and how does it corelate to TDD? Is test-first development
I've found that test first development can be painful if the workflow is slow.
I know that TDD helps a lot and I like this method of development
I don't know so much about Test-Driven Development (TDD), but I always hear that
I'm a big TDD enthusiast, and always strive to write tests before writing production
What are your opinions and experiences regarding using TDD when developing an user interface?
When doing TDD , how to tell that's enough tests for this class /
Recently, I have worked in a project were TDD (Test Driven Development) was used.

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.