Guys,
I was trying to solve one puzzle[1] and could not think of a way to
write tests first, the problem which I faced was the problem requires
reading XML and CSV file formats so do we normally write tests to
check the values read from the file?
If not when should we start with TDD in situation like this as you can
process the data only when you have read the file. I want to know the
experiences and the way you guys will approach to such kind of
problems.
[1] http://puzzlenode.com/puzzles/2
On Thu, Aug 18, 2011 at 8:11 PM, Mayank K.
[email protected] wrote:
I was trying to solve one puzzle[1] and could not think of a way to
write tests first, the problem which I faced was the problem requires
reading XML and CSV file formats so do we normally write tests to
check the values read from the file?
I have written tests which verify that a configuration reader parses
an XML file properly. But I am not sure whether it’s necessary to
make this a general rule. It may be that the parsing stage can be
tested indirectly by other tests which immediately show a wrong value
read, it may be that you need / want to test this separately. Write
those tests that suit your situation best.
If not when should we start with TDD in situation like this as you can
process the data only when you have read the file. I want to know the
experiences and the way you guys will approach to such kind of
problems.
I would usually have a class or classes representing the data read
from those files. In that situation you have a clean modularization
which means you can test reading and processing separately. And you
can easily add another input method for the configuration. Plus, you
can make the class representing the input contain validity checks
which will guarantee that the configuration is valid regardless from
where it was obtained.
Kind regards
robert