TestPlan scriptDir, Filename, and path resolution
Document

scriptDir, Filename, and path resolution

by Group Public on Thursday February 12 2009 @ 10:26:34 (1/1 Points)

Configuration ↪Reference ✑ Reply ✓ Stick It ✗ Ditch It ⚐ Tag It

A file, or script, can be referenced TestPlan in the scripting language, on the command line, or via Java module. These files are all resolved via a common resolution pattern.

Loading and scriptDir

The testplan command line accepts a --scriptDir=path argument which specifies an absolute pathname of where files and scripts can be located.

There are several paths added by default, such as the standard library path and the directory from where TestPlan was called. If a filename is specified as the entry unit then that path will be added as well.

Any number of additional directories can be specified with --scriptDir.

These paths will also be added to the Java classpath for locating your Java TestUnits.

Loading

Any time a file needs to be loaded, either via an explicit load, or implicit reference (such as executing a script) the entire set of scriptDir's will be checked to see if they contain the file.

In general the default paths are checked first, then the user specific paths in the order provided. However, you should avoid relying on this ordering; internal caching could possibly bypass the most correct match. Conflicts in names should as best as possible be resolved in your test units.

Saving

When specifying the name of a file for writing it is advised to use an absolute path name if you wish to keep the file after TestPlan exits. This avoids any clashes with a file of the same name which already exists, and allows you to clearly indicate where the file should be stored.

The This:Dir item can be used to identify the directory of the current script. To create a file in the same directory as the current script you can use %This:Dir%/myfile.ext.

The System.StartDir item can be used to get the directory in which testplan was started. This will be the current directory if launching from the command line, or the working directory if launched from another program. To create a file in the directory where testplan was run you can use %System.StartDir%/myfile.ext

If you nonetheless specify a relative file it will normally be created in the System.TempDir directory (which is set to your OS's normal temporary directory). Though see the note below about temporary files.

Temporary Files

Most functions that allow the creation of files follow a similar logic as to whether the file should be deleted or left intact when TestPlan exits.

Absolute filenames are considered to be persistent and will not be deleted when the program exists. To force an absolute file to be treated as temporary set unit.file.TempFilesAbs to true when creating the file.

Relative filenames, or situations where no name was specified, will be considered temporary files and deleted when the LogicalRoot exits. If you use exec you must thus be aware that after the exec'd unit completes the file will be deleted. If you wish to preserve relative files set unit.file.TempFiles to false when creating the file.

Special Name

Many functions allow simply omitting the filename to have a temporary file created. This will typically return the path in Return:Path.

In some cases a file must be specified for syntactic reasons. In these cases you can use a special item to indicate you'd like a temporary file. The item %Codes:TEMPFILE% will be recognized as a request to create a temporary.

SaveRequest %Request% %Codes:TEMPFILE%
© 2008-2010 edA-qa mort-ora-y
Using Persephone and TestPlan
Tag: