On 11/18/05, Jeff D. Chastain <[EMAIL PROTECTED]> wrote: > 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?
You have (at least) two possibilities: 1. write the test method to call setName(someValue) and then: assertEquals(expected=someValue,actual=obj.getName()); This tests that the set/get pair work as expected. 2. write a CFC to extend the one under test and add a getVariables() method then: obj = createObject("component","extendedCFC"); obj.setName(someValue); assertEquals(expected=someValue,actual=obj.getVariables().name); This tests that set actually sets variables.name correctly - but exposes implementation details. It's a tradeoff (not surprisingly) since you can test more atomic things if you use more knowledge of the implementation - which couples your test code to your implementation more closely (not a good thing in general). -- Sean A Corfield -- http://corfield.org/ Got frameworks? "If you're not annoying somebody, you're not really alive." -- Margaret Atwood ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:224707 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=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54