Thursday, October 25, 2007

Test Commonalities: Paths and Filenames

This is part two (and the first substantial post) in my Test Commonalities series. In this series, we discuss the test areas that come up over and over again across many projects. The goal is to create a good cheat sheet for each so we don't have to reinvent the wheel every single time. Today: paths and filenames.

Handling paths and filenames is a huge part of testing any time you have interaction with the file system. Every time you have an application that writes a file, or creates a directory, or reads a file, you have a system that should be tested for paths and file names.

So, what is this testing? Basically, when you read or write a file, you subject your system to the rules and conventions of the file system on which you are running. You are interacting with a third party just as much as that interface with another system.

So for each type of operating system, you need to understand the rules of the file system.

On Windows:
  • Paths, including file name and extension must be less than 256 characters*
  • File extensions are optional
  • File system is case insensitive
  • Certain paths change per user (e.g., a %USERHOME% is usually c:\Users\catherine)
  • "Reserved paths" are usually addressed by environment variable (e.g., a user's home directory, the default program storage location, the temp directory location)
  • "Reserved paths" are not in the same actual location across various OS versions
  • Certain directories require special privileges to write to them
  • Hidden and system files are denoted by file system attributes
  • Paths begin with a drive letter
  • Certain characters (e.g., : or / ) are illegal in path and file names
  • File extensions may be of any length from 0 to 250 characters
On UNIX/Linux/Mac**:
  • File system is case sensitive (except macs)
  • Files beginning with a . are generally hidden from the user
  • Hidden and system files are denoted by the file name and location
  • Certain directories require special privileges to write to them
  • Certain paths change per user (e.g., ~/ takes you to a user's home directory)
  • Paths begin with a /
  • Directory delimiters in a path must be /
  • Certain characters (e.g., /) are illegal in path and file names.
You wouldn't skip testing your system's interface with a billing system, or with an HL7 feed. Don't skip testing your system's interface with the file system, either.

*Disclaimer: Yes, there are ways around this, but they're generally ill-supported and will get you in trouble.
** Disclaimer part 2: Yes, I know there are a lot of different file systems available for UNIXand UNIX-like operating systems and they don't all match. This post is intended to cover mostly client systems where this kind of interaction is likely. Do your own research for your own wacky file system if you want to use one.

No comments:

Post a Comment