> So, I go to write a unit test around a simple bean object.  First test, 
> setName(name) .... Okay, obviously I need to pass in a string to this 
> method, but as it is a setter, it does not return anything.  So, what 
> am I really testing here ... that the method does not blow up, or how 
> would I really test that it is doing what it is supposed to?  Do I 
> actually test the setName function by calling getName afterwards (in 
> the same test function) and then comparing the expected result?

Here is some food for thought too...
There is a common principle in the JUnit world: Don't test getters and setters 
unless they do something special.
The reasoning is that in general they are too simple to break. Most 
getter/setters are only doing a cfset and cfreturn. So if you were to test 
them, you would really only be testing that you got the variable name right. 

One good resource is the Oracle white paper:
http://www.oracle.com/technology/products/jdev/collateral/papers/10g/GettingStartedWithUnitTesting.pdf
Which states this at the top of page 13. It also has a number of other very 
good principles.

-- 
Rob Blackburn
http://www.rbdev.net

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:224738
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to