title: Making a private method public to unit test it...good idea?
body: <p><sub><strong>Moderator Note:</strong>  <em>There are already 39 answers posted here (some have been deleted).</em>  Before you post <em>your</em> answer, consider whether or not you can add something meaningful to the discussion.  You're more than likely just repeating what someone else has already said.</sub></p>
  
  <hr>
  
  <p>I occasionally find myself needing to make a private method in a class public just to write some unit tests for it.</p>
  
  <p>Usually this would be because the method contains logic shared between other methods in the class and it's tidier to test the logic on its own, or another reason could be possible be I want to test logic used in synchronous threads without having to worry about threading problems.</p>
  
  <p>Do other people find themselves doing this, because I don't really like doing it?? I personally think the bonuses outweigh the problems of making a method public which doesn't really provide any service outside of the class...</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Thanks for answers everyone, seems to have piqued peoples' interest. I think the general consensus is testing should happen via the public API as this is the only way a class will ever be used, and I do agree with this. The couple of cases I mentioned above where I would do this above were uncommon cases and I thought the benefits of doing it was worth it.</p>
  
  <p>I can however, see everyones point that it should never really happen. And when thinking about it a bit more I think changing your code to accommodate tests is a bad idea - after all I suppose testing is a support tool in a way and changing a system to 'support a support tool' if you will, is blatant bad practice.</p>