Hi Tim,
Am 23.01.2013 16:07, schrieb Tim Ottinger:
TDD is constantly about modifying the code to fit the tests, since
the test comes first and the code is written to satisfy it. I don't
understand the objection here.
that maybe a misunderstanding because of my english.
The objection I wanted to express is: I don't want to introduce
(production-)code that only exists to be able to test something. As an
ugly example:
// bad:
class Renderer {
public function render( graphics : Graphics, ?testGraphics :
MockGraphics = null ) {
if ( testGraphics != null ) {
graphics = testGraphics;
}
graphics.drawSomething();
}
}
That is what I meant by "code that fits the test".
One could argue that an adapter like a GraphicsView is a more elegant,
but similar artificial construct, that is only introduced to be able to
test the real object. Since I just started, I wanted to know, how this
is handled by experienced TDD-practitioners.
But I followed your suggestions, wrote a thin Adapter/Wrapper and that
works very nice for now!
Thanks!