« Return to Thread: How to TDD a Reporting Application?

Re: How to TDD a Reporting Application?

by ulu :: Rate this Message:

Reply to Author | View in Thread

--- In testdrivendevelopment@..., "fsharpmike"
<fsharpmike@...> wrote:

>
> Hi,
>
>     Could anyone provide any pointers on how to go about developing a
> reporting application using TDD?  That is, an application that is
> focused on reading from different tables in the database, combining
> the data in various ways, then formatting and outputting it?
>
> Thanks,
> Mike
>

I'm developing Inka (http://sourceforge.net/projects/inka) using TDD
from the very beginning (I learned a lot doing that). My goal was,
however, to create a reporting tool that is independent of its data
source.

Anyway, first I wrote a simple test that verified that a string is
printed at the specified position. I used TypeMock and mocked the
Graphics object. I wrote an expectation that the method DrawString
should be called, with appropriate arguments. After I made it pass, I
refactored the code and got rid of the Graphics dependency. Now I can
write my tests against a mocked ICanvas interface. Which is good,
since I can write implementations for printing and exporting to pdf
and stuff. However, my next step was to get rid of this dependency
too, since I didn't want to print something each time I want to test
it. So, I refactored it into a preparation stage, where all elements
are assigned their values and placed at the correct positions, and the
actual printing stage. Now the preparation is completely independent
of the printing.

After that I started more refactoring. I made each element
independent, so that I can create it without creating the whole
report, and check its properties. For example, a data-driven element
should have its Value correct given the correct data source and
format. It should be testable without creating the whole report, or
even the parent section. on the other hand, the layout should be
testable independently of the concrete elements. So, while adding new
features, I'm going from testing the big picture to smaller units, but
I still have the first test to make sure that everything is wired
together correctly.

One big mistake was not introducing the paging engine early. After I
was finished with one-page layout, I discovered that implementing
paging requires much re-design, and in the process many existing tests
began to break. Was it the flaw of the TDD process? I believe that
adding the paging capabilities was not an additional feature, but
rather change of the requirements. Also, my mistake was to put a lot
of design decisions (versus client requirements) into tests.

ulu

 « Return to Thread: How to TDD a Reporting Application?