[TFUI] Re: [XP] TDD with web applications

Phlip <[email protected]> Wed, 28 Jun 2006 11:58:09 -0700
Newsgroups gmane.comp.programming.test-first-user-interfaces,gmane.comp.programming.extreme-programming
Message-ID <[email protected]>
Sammy Larbi wrote:

> A third group, which I will put myself in, is those who've never seen it
> as a possibility.  How do you test that a circle (for example) was drawn
> on the screen?  Sure, you can test that the object was created and such,
> but how do you know it didn't actually draw a square?

You are probably not writing the entire pipeline from logical data, to
vector commands (draw a square!), to the raster commands in your
driver layer.

You generally intercept commands, in their layer, and test for
incidental signals. For example, a program called Dot, part of
GraphViz, converts graphics commands into formatted output. It has a
pluggable output system that plugs in renderers for PNG, GIF, SVG, and
so on. To test-first the Dot program, you would write a mock renderer
that merely detected an input command suggesting a square would indeed
produce the square command at the layer boundary.

Each layer has its own test needs, and these must go into custom
fixtures. The actual output from Dot might go into a GDI window
(Win32) via the WM_PAINT command. That uses the familiar brush and
paint commands to simulate painting pixels. That's efficient because a
driver instantly converts such commands into hardware commands. To
test all that, re-use your WM_PAINT command, and pass it a device
context with its "metafile" output turned on. Now the commands go into
an .EMF file, and you can view this in MSPaint, and you can call more
metafile functions to read it and spot-check its commands.

Finally, embracing TDD may involve discarding tried-and-true
technologies that can't be tested. To avoid molesting your driver
layer just to TDD some art, you can instead switch to a full-featured
Canvas object that retains graphic commands as objects. Then you
trivially query the objects back and check their properties to test.

-- 
  Phlip
  http://c2.com/cgi/wiki?ZeekLand  <-- NOT a blog!!


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Yahoo! Groups gets a make over. See the new email design.
http://us.click.yahoo.com/XISQkA/lOaOAA/yQLSAA/nhFolB/TM
--------------------------------------------------------------------~-> 

To unsubscribe, email:
TestFirstUserInterfaces-unsubscribe-hHKSG33TihhbjbujkaE4pw@public.gmane.org
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/TestFirstUserInterfaces/

<*> To unsubscribe from this group, send an email to:
    TestFirstUserInterfaces-unsubscribe-hHKSG33TihhbjbujkaE4pw@public.gmane.org

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/