The consensus seems to be not to test private methods when doing TDD.
Should Private/Protected methods be under unit test?
I keep hitting this same scenario. I have a private method (as an example it switches all options to off). It changes lots of state and is called by a few public methods. The changes that the private method makes to the state will remain the same regardless of which public methods get called (all options get set to off).
What's the best way to test the functionality of this private method without adding many tests that effectively do the same thing?
btw, I'm using QUnit to test Javascript objects.
Here is an overly simplified version of my class.
http://jsfiddle.net/twistedinferno/UMgAx/
Edit
What I'm really trying ask here is not 'should I or shouldnt I test private methods' as that has already been answered and the answer to that is no. I want to know how do I best test each public method bearing in mind that many of the assertions will be the same due to the use of my private method. The same private method gets called by many public methods. Is it ok to have a lot of duplicate assertions to test the change of state that occurs when each one of many public methods call my private method?
new fiddle with tests http://jsfiddle.net/twistedinferno/JHzWh/