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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:21:36+00:00 2026-05-31T05:21:36+00:00

I believe everyone encounters a case when there’s necessity to test internal wiring of

  • 0

I believe everyone encounters a case when there’s necessity to test internal wiring of the class/object. I know that in compiled languages this could be done through conditional compiling. Is this what I should do for JavaScript as well? What’s the usual way to accomplish such task? Maybe I should just treat the class/object as a Black Box and only test it’s outcomes?

  • 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-31T05:21:37+00:00Added an answer on May 31, 2026 at 5:21 am

    Testing object’s public contract (ie. black box testing you mentioned) most of the times should be enough. Proper test coverage of public members should exercise majority of private/internals as well. After all, why would user of your class (be it other programmer, other objects/collaborators) care about what your objects do inside?

    When you arrive at the point that you feel a strong need of testing internals, treat it as an opportunity to improve. Usually, such need is a result of your code communicating you something – “maybe I shouldn’t be private”, “maybe it’s worth to refactor me into separate being”.

    Also, keep in mind that testing internals makes your tests more fragile. While your object/class functionality (contract) might remain the same, implementation might change fairly often. Think about replacing your own pieces of code with 3rd party/external libraries (quite common change) – is this a reason to break your tests? It is not.

    I realize sometimes you just have to test internals – but IMO, it’s better to stop then and think whether you can make your code better (very often you’ll find out you indeed can!). Treat testing internals as a last resort when everything else failed.

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

Sidebar

Related Questions

Ok, I know everyone thinks IFrames are bad an I know that. But I
I know that there are several very similarly-related questions on this website, however after
The following snippet does work for what I need. I believe though that there
I believe that the rallytagpicker is definitely a useful component. However, I do not
I believe my problem stems from my use of weights and the RelativeLayout that
I'm having trouble getting the setMap(null); function that everyone seems to be recommending to
I'm not sure but I believe that Python is -next to Objective-C- somewhat natural
(Title and contents updated after reading Alex's answer) In general I believe that it's
I can't believe I can't google this. I don't know what to google. public
I know that the following function returns the current Windows user's name in domain\username

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.