<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">Hi All,<DIV><BR class="khtml-block-placeholder"></DIV><DIV>I am writing a python Grid class, which is composed of several objects of class Tile.  A simple example of this is</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>class Tile(object):</DIV><DIV>    def __init__(self,x=0,y=0,width=1,height=1):</DIV><DIV>        """ Initialize tile position """</DIV><DIV>        self.x = x</DIV><DIV>        self.y = y</DIV><DIV>        self.width = width</DIV><DIV>        self.height = height</DIV><DIV>        self.area = width*height</DIV><DIV>    </DIV><DIV>    def get_area(self):</DIV><DIV>        return self.area</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>class Grid(object):</DIV><DIV>    def __init__(self,dimensions):</DIV><DIV>        """Initialize the size of the grid and add tiles."""</DIV><DIV>        self.dimensions = dimensions</DIV><DIV>        num_x,num_y,width,height = self.dimensions</DIV><DIV>        self.tiles = [Tile(x,y,width,height) for x in range(num_x) for y in range(num_y)]</DIV><DIV>    </DIV><DIV>    def get_area(self):</DIV><DIV>        area = 0</DIV><DIV>        for t in self.tiles:</DIV><DIV>            area += t.get_area()</DIV><DIV>        return area</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>so that a Grid object owns several Tile objects, and that methods of the Grid object internally require methods of the tile objects.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>My question is how to test this system.  I can write independent unit tests for the Tile class no problem since it is isolated itself.  However, how do I test the Grid behavior, independently of a properly-functioning Tile class (i.e. how do I isolate the tests of the Grid object)?  Do I use mock Tile objects?  If so, what is the best way to create these?</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Thanks for any help or links to resources you can give.  I'm new to tdd, so any advice helps!</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Cheers,</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Julius</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><DIV> <SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><DIV>-----------------------------------------------------</DIV><DIV><A href="http://openwetware.org/wiki/User:Lucks">http://openwetware.org/wiki/User:Lucks</A></DIV><DIV>-----------------------------------------------------</DIV><DIV><BR class="khtml-block-placeholder"></DIV><BR class="Apple-interchange-newline"></SPAN> </DIV><BR></DIV></BODY></HTML>