views:

50

answers:

2

We've inherited an application that uses a script to import data from a text file, but doesn't test the import script.

I'd like to write some tests for that script, and will need test text files (these are not fixture files).

Where would you normally put those files? A data directory? In the new support directory?

A: 

I disagree, they are fixtures as they are sample test data you're testing with. They would live in spec/fixtures

Ryan Bigg
Wow, looks like we have a little battle going on. The original script (definitely not written by myself) Does all sorts of wonderful text manipulating where they could've just loaded the data into a regular table. I suppose it
btelles
Perhaps the disagreement is just the difference in how one does unit testing vs how one does functional testing. Both need to be done.
Jeff Waltzer
A: 

You should decouple your import from the file IO. Then you should be able to feed in test strings into your importer with out having to make 'test files'.

Jeff Waltzer
And if the test file is 4mb? What then? a 4MB string. Awesome.
Ryan Bigg
Sounds like you've had to test a few text files.Lucky for me, the rows of data are small enough to fit in a simple class (or organized well enough to be imported into a data structure like a FasterCSV object). Then any test files would in fact turn into proper fixtures.Funny how both of you were right. :-)
btelles