RubyFlow The Ruby and Rails community linklog

Private Methods: To Test or Not To Test?

Some say that you should only test your public API. I disagree officially in this blog post that shows pros and cons of testing private methods, too. I’d love to hear your opinions!

Comments

I left a comment on your blog, but here’s my take on the topic: http://blog.rubybestpractices.com/posts/gregory/034-issue-5-testing-antipatterns.html

Basically, I think your argument is that you should test the non-trivial private API of your code (i.e. its internals / developer API). I agree with that, but I disagree that your internal API should be marking its methods as private. Details in the article linked above.

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in