Page 1 of 1
Testing PHP Csv Utilities - use real csv files?
Posted: Tue Oct 07, 2008 3:06 pm
by Luke
I have decided to rewrite my unit tests for PHP CSV Utilities before releasing version 0.3. One thing that I've been wondering about is how to test my auto-detector and even my reader. Should I be using actual csv files? Should I be somehow "mocking" a csv file? It seems to me that testing with actual csv files is somehow more related to smoke testing. Am I wrong?
Re: Testing PHP Csv Utilities - use real csv files?
Posted: Tue Oct 07, 2008 3:10 pm
by onion2k
When I test code that handles files I usually make a bunch of files that represent all the different styles and types of files the code needs to deal with. For example, I have a standard directory of test images in different formats, resolutions, landscape/portrait, etc.
No idea if that's a 'standard' way of doing things mind you. It's just what works for me.
Re: Testing PHP Csv Utilities - use real csv files?
Posted: Tue Oct 07, 2008 3:13 pm
by Luke
Yea that's exactly what I've done. I have a list of files in my tests called "bad-delimiter.csv", "commas-100-lines.csv", etc. I guess that's really the only way, eh?
Re: Testing PHP Csv Utilities - use real csv files?
Posted: Tue Oct 07, 2008 3:18 pm
by onion2k
You could write unit tests that test the code against those files I guess. I did that for one of my image projects.
Re: Testing PHP Csv Utilities - use real csv files?
Posted: Tue Oct 07, 2008 3:21 pm
by Luke
Yep, that's how I'm doing it now. I just wasn't sure if that was right. So what is a smoke test then?

Re: Testing PHP Csv Utilities - use real csv files?
Posted: Wed Oct 08, 2008 5:52 am
by josh
You have to be careful that if you write data to a file in one test, that the file gets reset before the next test, otherwise your tests will get too coupled to be meaningful
Re: Testing PHP Csv Utilities - use real csv files?
Posted: Wed Oct 08, 2008 5:58 am
by Luke
Oh yea of course... I do that in my setUp and tearDown() methods. Good advice though... thanks
