This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "test geter and setter" Watch "test geter and setter" New topic

test geter and setter

sam liya
Ranch Hand

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

Joined: Nov 27, 2006
Posts: 430

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

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
I agree. Here's the link:
subject: test geter and setter
It's not a secret anymore!