next up previous contents
Next: Temporary Test Data (class Up: Test Data Organization Previous: Resources as Files (class   Contents

Test Data in a Directory (class FileRepo)

Sometimes it is desired to keep test data separately from source code. In this case test data may be kept in a directory in the file system.

Class junit.extensions.repo.FileRepo provides access to files in that directory. It should be constructed and used as follows:

protected void setUp() {
    repo = new FileRepo("/path/to/base/directory");
}
...
File file = repo.getFile("test.properties");

In the above example, object file is a handle to physical file with absolute path equal to /path/to/base/directory/test.properties.

Test data may also be organized into subdirectories, whose structure resembles package structure of test cases. Please see documentation for FileRepo in [Repo API].

See also: