[Tutor] How do I test file operations (Such as opening, reading, writing, etc.)?

Alan Gauld alan.gauld at btinternet.com
Fri Jan 29 07:35:56 EST 2016


On 29/01/16 07:09, Ben Finney wrote:

>>   Create a directory and copy your pristine tree into the directory
>>   and make the base directory for the important data files
>>   configurable. Also known as parameterization.
> 
> I consider that a poor option; real files complicate the test setup and
> cleanup, they are always going to be slower, and they can lead to false
> positives and false negatives in the test results.

There are pros and cons to all the options.

File simulation is faster and fine for unit testing functionality,
but not so good for testing the overall system. Simulated files
can lead to false positives precisely because they are faster
than real files. Recognising slow access times - especially
on big data sets - are a vital part of testing any application.

In an ideal world parameterize so that you use file simulation
for basic functional unit testing and then use a dummy real file
system for integration, performance and system testing (and
probably user testing too). Finally, acceptance testing will
likely have to run on the real (actual) filesystem.

Having configurable test environments is pretty much essential.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list