next up previous contents
Next: Archive Up: Patterns of Uses of Previous: Patterns of Uses of   Contents


Prototype

This idea is similar to the Prototype design pattern used in object-oriented software design.

The intent is to copy test data from a test data repository to a temporary location in the file system and provide access to the copy of the test data.

The motivation for such test data repository is to be able to modify its test data when tests runs, without clobbering the test data permanently. Test cases can read from and write to (temporary copies of) files from the repository being guaranteed that the initial state of the repository will be the same on the next run of the test cases.

All temporary files must be deleted from the file system when the repository is no longer needed, for example, when the test case tears down. (See figure 3).

Figure 3: Prototype repository
\includegraphics[scale=.4]{prototype.eps}

It's worth noting that the entire repository does not have to be ``cloned,'' i.e., not all test data from the repository has to be copied to a temporary directory. For efficiency, the test data repository may use a ``lazy'' approach: create a temporary file only when that file is requested. (See figure 4).

Figure 4: Prototype repository
\includegraphics[scale=.4]{copy.eps}


next up previous contents
Next: Archive Up: Patterns of Uses of Previous: Patterns of Uses of   Contents