Offline execution - The test execution batch file

From a TestArchitect client session, you can generate a batch file that invokes the command line tool to perform your tests.
Note: The following content discusses the batch files that are typically created in the Windows environment, and hence uses commands and other keywords that are specific to Windows. The batch files created under Linux and macOS are, however, quite similar.

The test execution command line

Being a Java program, the command line tool, TACommandLine.jar, is passed as a parameter to the java executable. The TACommandLine command takes the following form:

java -jar -Xmx512m TACommandLine.jar
with various arguments, as outlined in Command options, following it. (Note also that, as it appears in the generated batch file, filepaths generally precede both the java executable and the TACommandLine.jar file.)

Aside from the file (TACommandLine.jar) to be executed, the java executable is passed two arguments:

-jar
Instructs java to execute a program encapsulated in the JAR file.
-Xmx <Size>
Specifies the maximum size, in bytes, of the memory allocation pool. This value must be a multiple of 1024 greater than 2MB.
Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes.
Note: The default value is 512MB.

Running on a single controller

In Windows, the generated batch file to execute a test only single controller has this form:

:TAExecute0
@echo off 
set JAVA_TOOL_OPTIONS=
set _JAVA_OPTIONS=
cls 
title TestArchitect - Command Line Tool 

  [TACommandLine.jar command line1]
 
exit
The Windows batch commands and keywords in the file are as follows:
:TAExecute0
The colon (:) designates a batch file label which, in this case, is TAExecute0. Labels serve as reference points in a batch file for other lines in the file, usually as go to points. For a single-controller batch file, the label does not have any practical use. It does come into play for multiple-controller batch files, however, as will be discussed later.
@echo off
Instructs the batch file interpreter not to display any future commands to the screen.
set JAVA_TOOL_OPTIONS=
JAVA_TOOL_OPTIONS is an environment variable which allows you to specify the initialization of tools – specifically, the launching of native or Java programming language agents.
set _JAVA_OPTIONS=
JAVA_OPTIONS is an environment variable.
cls
Clear the complete contents of the screen and leave only a prompt.
title TestArchitect - Command Line Tool
The command line window's title is assigned the name TestArchitect - Command Line Tool.
exit
Exit and close the command line/terminal.

Running a test on multiple controllers

The Execute Test dialog box affords you the option to direct your test to be executed on more than a single controller concurrently. When you generate a batch file for multiple controllers, TestArchitect loads it with separate TACommandLine lines which are identical except for the exechost (controller host) and possibly execport arguments. As an example, the Windows batch file for a three-controller test run might take the following form:
if not "%1" == "" goto :%1
start "TAExecute0" cmd /k "%~dpfx0" TAExecute0
start "TAExecute1" cmd /k "%~dpfx0" TAExecute1
start "TAExecute2" cmd /k "%~dpfx0" TAExecute2
exit
:TAExecute0
@echo off 
set JAVA_TOOL_OPTIONS=
set _JAVA_OPTIONS=
cls 
title TestArchitect - Command Line Tool 

  [TACommandLine.jar command line1]

exit
:TAExecute1
@echo off 
set JAVA_TOOL_OPTIONS=
set _JAVA_OPTIONS=
cls 
title TestArchitect - Command Line Tool 

  [TACommandLine.jar command line1]

exit
:TAExecute2
@echo off 
set JAVA_TOOL_OPTIONS=
set _JAVA_OPTIONS=
cls 
title TestArchitect - Command Line Tool 

  [TACommandLine.jar command line1]

exit
Some of the lines not seen earlier include:
if not "%1" == "" goto :%1
This allows for an optional parameter (represented by %1) to be passed to the batch file to allow it to execute on one and only one of the controllers specified within it. For example, were the above batch file to be named Calculation.bat, the command Calculation.bat TAExecute2 would cause the test to run only on the controller specified in the last block of the batch file.
start "TAExecute<Number>" cmd /k "%~dpfx0" TAExecute<Number>
Without delving into details, each start command launches a separate instance of Windows' cmd shell, which then launches the batch code for the TACommandLine execution for one of the specified controllers. By using start to launch each controller-specific test, you ensure that the three tests run asynchronously. (Without start, each test would not begin until the one before it completed.)

Running a test on multiple mobile devices

As with multiple controllers, you can elect from the Execute Test dialog box to execute a test on multiple devices. The generated batch file looks similar to that of one of the above two cases (depending upon whether one or multiple controllers are involved). For each TACommandLine, an additional argument, /devices, is applied , to specify one or more devices attached to the respective controller.
/devices "<Device Name 1>;<Device Name 2>"

Running multiple test modules

When you specify a serial test run, a separate TACommandLine line is generated for each test module. (One exception, discussed below, is when you specify a test suite and accept the default of running all test module sections and test cases.) In the event that you are also specifying multiple hardware targets (controllers or devices), the number of command lines is multiplied accordingly. For example, we can expand on the above example of executing on three controllers by also specifying two test modules, tm01 and tm02:

if not "%1" == "" goto :%1
start "TAExecute0" cmd /k "%~dpfx0" TAExecute0
start "TAExecute1" cmd /k "%~dpfx0" TAExecute1
start "TAExecute2" cmd /k "%~dpfx0" TAExecute2
exit
:TAExecute0
@echo off 
set JAVA_TOOL_OPTIONS=
set _JAVA_OPTIONS=
cls 
title TestArchitect - Command Line Tool 

  [TACommandLine.jar command line for tm011]
  [TACommandLine.jar command line for tm021]

exit
:TAExecute1
@echo off 
set JAVA_TOOL_OPTIONS=
set _JAVA_OPTIONS=
cls 
title TestArchitect - Command Line Tool 

  [TACommandLine.jar command line for tm011]
  [TACommandLine.jar command line for tm021]

exit
:TAExecute2
@echo off 
set JAVA_TOOL_OPTIONS=
set _JAVA_OPTIONS=
cls 
title TestArchitect - Command Line Tool 

  [TACommandLine.jar command line for tm011]
  [TACommandLine.jar command line for tm021]

exit

Running multiple test modules with a test suite

When you specify a test suite for execution, the form of your batch file depends on whether you make any modifications to the Test Modules panel of the Execute Test dialog box. (By modification, we mean deselect a test case or any other section of any test module.) If you do make a modification, your batch file has the same form as the previous case – that is, a TACommandLine is created for each test module. This is necessary so that the /mod parameter of at least one TACommandLine string can specify exactly which test module sections are to be executed.

For example, assuming we have elected to skip the first two test cases of the Calculation test module, the value for our /mod option might look like:
/mod "\Car Rental Tests\Calculation<tab>initial{#@}TC 03{#@}final<tab>10kkm3qfs1"
in which the center <Test Module Sections> segment, initial{#@}TC 03{#@}final, specifies that only the initial, final, and test case TC03 sections are to be executed.
However, if you generate a batch file for a test suite without deselecting any of the test module sections, there is no need for a separate command line for each test module. (Or, more generally, no need for more than one command line per hardware target.) Instead, each TACommandLine line can specify the entire test suite, again via the /mod argument. For example:
/mod "\Test Suites\Smoke Tests<tab><tab>qfs1Pb9ui4"
specifies a test suite in place of a test module. Note also the lack of a central <Test Module Sections> segment. This directs the TestArchitect interpreter to execute each test module of the test suite, as well as each section of each test module.