Monday, October 29, 2007

Test Commonalities: File Attributes

Welcome to part three of my Test Commonalities series! In this series we talk about common items that come up over and over across projects.

A file is generally treated by a program - and by most users - as a unitary item. That is, a file is a thing, one single thing. In general, though, that's simply not true. A file is actually a thing (the file itself) and a bunch of meta-information. Depending on the context, these are given different names, but in general they are attributes of the file.

So, when we test file system attributes what do we need to consider?

Well, first we need to define the scope of the concern. In some cases, the system will be isolated on a file system. For example, a simple desktop application may never access a remote file system. In other cases the system will involve a remote file system. Examples of this include sync applications and applications allowing or utilizing a network drive.

If we are isolated on a single system, we must consider the following:
  • Performing legal operations. For example, read a hidden file, write to an archiveable file.
  • Attempting illegal operations. For example, write to a read-only file.
  • Displaying things to the user that match what the operating system displays. For example, show a read-only file to the user.
  • Displaying things to the user that don't match what the operating system displays. For example, show a hidden file to the user.
  • Changing an attribute of the file
  • Preserving file attributes across modifications of the file. For example, writing to a hidden file should leave it hidden.
  • Avoiding unintentional modifications to attributes. For example, reading a file should not update the modified time.
  • Inherited attributes. For example, if a directory is read-only, a file inside that directory can be expected to be read-only.
When there are multiple systems to consider, we must test everything above and some additional items:
  • Unavailable attributes. Some systems may not support certain attributes that other systems do. For example, older versions of Windows do not have an archiveable attribute.
  • Additional attributes. This is the inverse of unavailable attributes. For example, Windows Vista offers extended attributes not available to older versions of the operating system.
  • Different attribute names. In particular, when crossing operating systems (e.g., Mac to Windows), some of the same attributes may have different names.
  • Entirely different attributes. In particular when crossing operating systems. This is a special instance of unavailable attributes and different attributes.
  • Transferring attributes. When transferring a file, the attributes for that file must also be transferred. This is often a separate action from writing the file itself.
In short, there's a lot more to a file than just the file itself, and it all needs testing. Maybe your program deals with attributes already, maybe it doesn't, but no matter how isolated your program is, you have to assume that files and file attributes can change underneath it, so test away!

No comments:

Post a Comment