in Education by
Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago. Improve this question I have read this post about how to test private methods. I usually do not test them, because I always thought it's faster to test only public methods that will be called from outside the object. Do you test private methods? Should I always test them? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
I do not unit test private methods. A private method is an implementation detail that should be hidden to the users of the class. Testing private methods breaks encapsulation. If I find that the private method is huge or complex or important enough to require its own tests, I just put it in another class and make it public there (Method Object). Then I can easily test the previously-private-but-now-public method that now lives on its own class.

Related questions

0 votes
    As it currently stands, this question is not a good fit for our Q&A format. We expect answers to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 27, 2022 in Education by JackTerrance
0 votes
    As it currently stands, this question is not a good fit for our Q&A format. We expect answers to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 24, 2022 in Education by JackTerrance
0 votes
    Assymmetric Encryption: Why can a message encrypted with the Public Key only be decrypted with the ... topic in portion Database Programming Techniques of Database Management...
asked Oct 10, 2021 in Education by JackTerrance
0 votes
    Explain the co-relation between the following: Narrow and Broad perspective of Public Administration (Private ... Public administration). Please answer the above question....
asked Aug 4, 2022 in Education by JackTerrance
0 votes
    I'm trying to install a GoDaddy SSL certificate on a new load balancer I'm setting up on Amazon AWS. I ... verify this. Any ideas? Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    24 ina rsa system the public key(e,n) of user a is defined as (7,187).Calculate totient(n) and private ... you encrypt message m=88? Select the correct answer from above options...
asked Dec 20, 2021 in Education by JackTerrance
0 votes
    What is a cloud-hosted service of Docker providing registry capabilities for public and private content? 1. Docker Images 2. Docker Alpine 3. Docker Hub 4. Docker Compose...
asked Jun 21, 2021 in Technology by JackTerrance
0 votes
    Which of the following networks extends a private network across public networks? local area network virtual private network enterprise private network storage area network...
asked Jan 10, 2021 in Technology by JackTerrance
0 votes
    Question 15: 15. .is a type of response test used in computing as an attempt to ensure that the response is ... code c) New code Select the correct answer from above options...
asked Dec 15, 2021 in Education by JackTerrance
0 votes
    Who should be responsible for test automation? Developers or the QA?...
asked Jul 10, 2021 in Technology by JackTerrance
0 votes
0 votes
    Which of the following refers to stealing one's idea or invention of others and use it for their own benefits? Piracy Plagiarism Intellectual property rights All of the above...
asked Mar 4, 2021 in Technology by JackTerrance
0 votes
    1. What are the different ways in which the independence of judiciary is ensured? Choose the odd ones out. i. ... in the appointment of judges. Please answer the above question....
asked Aug 4, 2022 in Education by JackTerrance
...