Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2012
    Posts
    4
    Rep Power
    0

    Default private helper methods

    (1) In unit testing, should you call private ‘helper’ methods of a class directly?

    probably not, but why, is it because your not supposed to "touch" any private methods and instead use a getter method?

  2. #2
    techiepro is offline Member
    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0

    Default Re: private helper methods

    Did not got your question. Can you please elaborate ?

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,050
    Rep Power
    20

    Default Re: private helper methods

    How can a class call a private method on another class?
    That should answer your question.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  4. #4
    techiepro is offline Member
    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,050
    Rep Power
    20

    Default Re: private helper methods

    Aside from that, since using reflection to get around access modifiers is plain evil.
    Possibly from the dawn of time.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  6. #6
    techiepro is offline Member
    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0

    Default Re: private helper methods

    That is the only solution -- Reflection. Think like this...for accessing private information of any person or organization...it has to be plan evil

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,050
    Rep Power
    20

    Default Re: private helper methods

    Well, yes.
    Which I suppose goes back to your first reply.
    We need more info from the OP as the question doesn't make much sense.

    Actually, I take that back, as I had an argument with someone on here a year or so ago about the value of unit testing private methods directly (as opposed to testing them in passing via the public/protected ones). So clearly some mad people think it makes sense.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 1
    Last Post: 10-05-2011, 12:15 AM
  2. Replies: 1
    Last Post: 09-09-2011, 06:57 PM
  3. Replies: 3
    Last Post: 05-05-2011, 03:33 PM
  4. Multiple private methods
    By java4deepak in forum New To Java
    Replies: 4
    Last Post: 01-05-2011, 01:05 PM
  5. Replies: 17
    Last Post: 10-14-2010, 10:26 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •