[TFUI] Re: [XP] TDD Quandary
Phlip <phlipcpp-/[email protected]>
| Newsgroups | gmane.comp.programming.test-first-user-interfaces,gmane.comp.programming.extreme-programming |
|---|---|
| Message-ID | <[email protected]> |
bigbaseballer wrote:
> How in the world do I test drive graphics (DirectX)
> code. That is,
> code that really does very little data manipulation
> at all, but
> basically just works with an API to get things done.
> And by done, I
> mean drawing objects on the screen. Not something I
> can really "test"
> in the sense of having inputs and outputs and
> verifying them, it is
> just so complex that the closest thing to
> traditional unit testing I
> could do is verify if certain pixels were certain
> colors ... and I
> assure you that would be a worthless test.
Write a temporary test function called 'reveal()'. It
will activate the MS Windows event queue, and allow a
testee to paint on the screen, and stay up until you
close it.
Call it at the bottom of your test case. The case will
set up a scenario, then each time you hit the test
button a window appears, and you can visually inspect
the results. When you like the appearance, comment out
the 'reveal()'.
Sadly, this technique boosts early velocity, and
without real assertions in your code the technique
will lead to source cannot refactor without high risk.
> The idea of mock objects comes up. Except, that idea
> has two
> implications. First of all, it means that I need to
> mock the DirectX
> API ... which I could do. It would be a bit
> annoying, but I could do
> it.
The style is called "Mock Graphics", and one should
use it as a last resort.
I recently wrote an OpenGL application using Mock
Graphics directly at the OpenGL boundary, based on the
glTrace package by Phil Frisbie, Jr. (When Kent Beck
finishes reviewing this effort, I might get to publish
it...)
The unwisely curious can get the sample code early, in
the CVS repository at http://sf.net/projects/flea
> But my BIGGEST issue with this approach is
> this: I have
> historically test driven a public interface, and
> then refactored some
> internal stuff. But basically, the test shows how
> the code is supposed
> to work from an external viewpoint. I get complete
> code coverage this
> way, and from talking to some people it sounds like
> I am on the right
> track. But what about this? My external interface is
> not supposed to
> really tell anything about the DirectX api. How do
> mocks come into
> play when I can't actually put them into use without
> making the
> interface aware of DirectX?
Here is a "does this help?" answer: Copy your code
into a scratch sandbox project, outside your version
control system, and then do Exploratory Testing and
Spike Solutions in it. Those are big words for "noodle
around". Make the code do what you want, and neglect
the tests. Then write beautiful tests that look like
they somehow came before the tested code.
Then copy the tests, line by line, back into the main
project, and use them to truly test-first the design
your scratch project arrived at.
=====
Phlip
http://industrialxp.org/community/bin/view/Main/TestFirstUserInterfaces
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com
------------------------ Yahoo! Groups Sponsor --------------------~-->
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/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/