On Jan 28, 2011, at 11:55 AM, David Kahn wrote: > If a private method is an intermediate value in a computation, just test > the end result. If a private method really needs to be tested > separately, then it's telling you that it wants to be public. > > I disagree -- for me public is what I want to expose to outside access, > regardless of complexity or size, where the private logic may actually be the > most complex, being called by a relatively light public function. Now this > may be a difference between TDD and BDD in pure forms, but for me I find if I > drive my methods, public or private with test first, that the end resulting > code is much more pliable. Also, if I have coverage on what becomes complex > private logic, at a more granular level -- then I have a much stronger > project an also address minute issues closer to the source. I am sure you > have your method of working that works for you, this is what I have found > effective and successful.
I would say that Marnen's position is very consistent from what I see from Kent Beck and others on the XP/TDD lists. It took me a while to get used to the approach, and I think it's important to clarify that Marnen isn't saying not to test complex private methods. He's just saying that if they are complex, maybe you've discovered another composed object's public method. SRP and all that . . . Best Wishes, Peter -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

