3.2.12 Include


Include - Include another script or compiled Java code.

When the argument is a TPR script in the language described by this document, the command will load ONLY procedures and variables from the script into the execution context and make them available to the calling script. This principle allows to build libraries with globally used variables and procedures and link them to scripts.

When the argument is a Java resource meaning a JAR or ZIP file or a classpath (directory structure containing .class files), the command adds it to the Java classpath and makes any compiled Java code it contains available for instantiation. This mechanism was introduced in v2.2 and it is intended to support dynamic loading of compiled Java scripts which may be subsequently called by the class name through the Run command.

Be aware that a dynamic update of the classpath affects the whole Java Virtual Machine (JVM) instance. If there are multiple automated testing processes, loading of such a resource makes its classes instantly available to all of them. If the file or path is already present on the classpath, the command does nothing and repeated calls of the same Include command cause no harm. Once the resource is loaded, eventual changes in the file system are not synchronized with the JVM. This means that it is not possible to apply changes to the resource code and recompile while Robot is running and it must be restarted to pick up any updates in the included library.

The name of the included file or path can be also specified dynamically through a variable. This eventually allows passing of the library name externally via the '-v' CLI option.


include <file_or_Java_resource>
* Red colour indicates obligatory parameters



-  A TPR script file or a Java resource (JAR/ZIP file or a classpath) to be included. Filename can be either relative (e.g. sayHello.tpr) or absolute (e.g. /root/scripts/sayHello.tpr). T-Plan Robot will check if the file exists and is readable during every script compilation and report an error if not. The file can be also specified via a variable (see examples).


The command always returns 0 (zero). If the specified file is not found, T-Plan Robot reports a syntax error rather than returning a non-zero return value.


Include sayHello.tpr

- Load all variables and procedures from a script called sayHello.tpr which is located in the same directory as the script calling this command.

Include /root/scripts/sayHello.tpr

- Load all variables and procedures from a script called sayHello.tpr which is located in the /root/scripts/ directory.

Var PROFILE=profile1.tpr
Include {PROFILE}

- Include a script specified by a variable. If you have more scripts with different configurations, you may then include another script from CLI using '-v PROFILE=profile2.tpr'.

Include C:\projects\TestLib\testlib.jar
Run mypackage.MyTestScript

- Load a Java library (JAR file) from the specified location and execute a script from there. This presumes that the JAR file contains a package (directory) called "mypackage" with a compiled class called MyTestScript which is a valid Java script (it extends the DefaultJavaTestScript class or at least implements the JavaTestScript interface). See the Run command below for more information.