Comments on: Unit Testing Private Methods in Javascript https://webdesignledger.com/unit-testing-private-methods-javascript/ By Web Designers for Web Designers Thu, 02 Mar 2017 07:41:00 +0000 hourly 1 https://wordpress.org/?v=6.5.5 By: divp https://webdesignledger.com/unit-testing-private-methods-javascript/#comment-983730 Thu, 02 Mar 2017 07:41:00 +0000 http://webdesignledger.com/?p=36259#comment-983730 In reply to Niels.

Unit testing is a software development process
in which the smallest testable parts of an application, called units,
are individually and independently scrutinized for proper operation…nicely explained

]]>
By: Niels https://webdesignledger.com/unit-testing-private-methods-javascript/#comment-983271 Tue, 06 Dec 2016 16:36:00 +0000 http://webdesignledger.com/?p=36259#comment-983271 Testing private methods is really bad. In this approach you’re exposing privates methods to production code, which is even worse. Private methods are there to be private, they allow you to split up your code in smaller chunks, nothing more nothing less. If you test private methods:

– Code coverage is USELESS, because sure, it will get 100%, but you still no idea if all functionalities are actually tested. Private methods should be touched in you’re unit tests and code coverage will reveal that.
– Code can NOT be changed with more confidence, you do not test if you actually keep functionality working when you change code, you just test if the individual methods work.

No approach to testing private methods is ‘best for you’. Don’t test private methods.. For more information there is a lot of TDD/Unit test books and material out there.

]]>
By: Piotr Nalepa https://webdesignledger.com/unit-testing-private-methods-javascript/#comment-982451 Thu, 23 Jun 2016 08:16:00 +0000 http://webdesignledger.com/?p=36259#comment-982451 I don’t agree with the pattern you proposed. If there any private methods in your code and you want to test them, then you should test them in the context of functionality, not in the context of method itself. The private methods are meant to help you with delivering a functionality to end user. If your code is nothing like a framework, then testing private methods is just a bad approach and should be avoided.

]]>