Developing your own User-scripted Java harness action

To created a scripted Java action, you must define the action, and modify the existing harness files to implement it.

The figure below provides an overview of the harness samples/java directory tree, in the TestArchitect program folder, and the files it contains.

Note:

This figure only describes the most important files and directories required to develop Java harness programs.

The tree resides under TA_INSTALL_DIR/harness samples/ (Windows), or /usr/local/testarchitect/harness_samples (Linux).

javadirectoryRoot directory of the sample Java harness.
java/executablesdirectoryExecutable files of Java harness programs.
java/executables/java_harnress.batfileA simple startup script. Its objective is to run the executable Java program file, java_harness.jar.
java/executables/java_harness.jarfileAn executable Java file invoked by the java_harness.bat file.
java/sourcedirectoryContains all necessary files used to implement Java harness code.
java/source/libdirectoryLibraries used to tell the harness code where to find the Java implementation of the automation library.
java/source/srcdirectoryContains source code that shows how to program for the Java harness.
java/source/build.xmlfileAn XML file that is used by Another Neat Tool (ANT) technology to build an excutable JAR file, which is java_harness.jar.

The folder java/source/src/com/testarchitect/java/user, contains the following three files:

TAMain.java is the startup Java script. Running this file executes the main() function, which sets the actions and starts the TestArchitect interpreter.

Lib_Interpret.java contains all the necessary functions for TestArchitect interpreter.

Your action definitions in Java may be grouped into separate Java classes, each of which is a .java file; it is in TAMain.java that the appropriate class for a given action is invoked. When a given action definition is requested by the interpreter, TAMain’s divert()function passes execution to the module in which that definition exists.

Only a single class, Mod_Example.java, exists in your harness samples/java/source/src/com/testarchitect/java/user directory (assuming you have a fresh installation of TestArchitect). In its unmodified form, it contains the Java code to define a single action, hello world, which writes the text string hello world to the results.

The convention is to organize user-scripted functions into multiple script class files, with the name of each such file prefixed with the string"Mod_" . If you add new actions, you may want to do so in new script files, depending on whether or not the actions logically fit within an existing module.

In this lesson you will write an action and add it toclass Mod_Example.java . In the subsequent lesson, you will write another action, but will create an entirely new script module to hold it.

As a rule, adding a new action to an existingmodule in the Java harness involves these steps:

  1. Add a line to the list of SetActions() function calls, declaring the action for the TestArchitect interpreter.
  2. Add an else-if clause to the divert() function, directing control to a function written to handle the new action. (In the next exercise, you will divert the hello action to aJava function called action_hello.)
  3. Create a function definition that provides the actual action-specific logic. (You will write theJava code for action_hello(), which will do the actual work for the hello action.)

Copyright © 2024 LogiGear Corporation. All rights reserved. LogiGear is a registered trademark, and Action Based Testing and TestArchitect are trademarks of LogiGear Corporation. All other trademarks contained herein are the property of their respective owners.

LogiGear Corporation

1730 S. Amphlett Blvd. Suite 200, San Mateo, CA 94402

Tel: +1 (650) 572-1400