From: Robert Klemme Date: 2011-08-20T18:14:01+09:00 Subject: Re: TDD when you have xml,csv or any file format to read On Thu, Aug 18, 2011 at 8:11 PM, Mayank Kohaley 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 -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/