Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Testing and the fly likes test geter and setter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "test geter and setter" Watch "test geter and setter" New topic
Author

test geter and setter

sam liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 1072
can we test get method or set method in junit?
Joachim Rohde
Ranch Hand

Joined: Nov 27, 2006
Posts: 423

Yes of course. Like any other method it can be tested.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
I think you are actually asking "the wrong question" - you shouldn't test methods, you should test behavior.

So, what behavior do you want to test?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: test geter and setter
 
Similar Threads
Rounding?
doubt pls!!
Doubt in Exception Handling.
Unable to call applet methods from javascript
compareTo with null Date object