SPONSORS:






User Tag List

Results 1 to 4 of 4

Thread: Private methods

  1. #1
    Junior Member
    Join Date
    Nov 2002
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Private methods

    Hi,
    Can you please let me know how to do Unit testing of "Private methods" in a class?
    Rgds

    ------------------

  2. #2
    Senior Member
    Join Date
    Oct 2001
    Location
    NC, United States
    Posts
    148
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Private methods

    i would think the way to go about it is to test using those methods within its scope....could you please clarify further what you are looking to do.

    ------------------
    -gram
    -gram

  3. #3
    Junior Member
    Join Date
    Nov 2002
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Private methods

    Generally class has public and private methods. These private methods can be called by public methods of that class only. Now we can't use Junit to test these private methods. Is thre any tools which can test private method also.

    ------------------

  4. #4
    Senior Member
    Join Date
    Aug 1999
    Location
    Cambridge, UK
    Posts
    470
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Private methods

    No tool will be able to test private methods directly. One way to get round this is to code an inner class with public methods which simply call the private methods of the outer class. That way you can do the testing (on the public methods of the inner class), but when it comes to release time you simply don't ship the inner class.
    For full details and a better explanation, see Thinking in Java at http://www.bruceeckel.com/

    ------------------

 

 

Posting Permissions

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

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 07:33 AM.

Copyright BetaSoft Inc.