JavaTestedApp Object

Applies to TestComplete 15.63, last modified on April 23, 2024

Description

The JavaTestedApp object corresponds to a Java or JavaFX application added to the project’s Tested Applications collection. It lets you access launch parameters of the application, such as the path to its .jar file and to the Java Virtual Machine used to run the application. It also provides methods used to launch and close the tested application from tests.

To obtain the JavaTestedApp object corresponding to a specific Java or JavaFX tested application, use any of the following:

  • TestedApps.AppName, where AppName is the application’s name in the Tested Applications collection and in the Project Explorer.

  • TestedApps.Items(Index), where Index is the zero-based index of the application in the Tested Applications collection.

Members

Example

The following example demonstrates how to add a Java application to the Tested Application collection, specify the application's launch parameters and run the application:

JavaScript, JScript

function Test()
{
  // Add a Java application to the project
  var ind = TestedApps.AddJavaApp();
  var app = TestedApps.Items(ind);

  // Specify Java application's launch parameters
  app.RunAsJar = true;
  app.JVMExecutable = "C:\\Program Files\\Java\\jre7\\Bin\\java.exe";
  app.JarFileName = "C:\\JavaApps\\SampleApp.jar";
  app.WorkFolder = "C:\\JavaApps";
  app.ApplicationArguments = "in data.txt";
  app.Options = "-verbose:class";

  // Launches the Java application
  app.Run();
  // Test the application
  …

  app.Close();
}

Python

def Test():
  # Add a Java application to the project
  ind = TestedApps.AddJavaApp();
  app = TestedApps.Items(ind);

  # Specify Java application's launch parameters
  app.RunAsJar = True;
  app.JVMExecutable = "C:\\Program Files\\Java\\jre7\\Bin\\java.exe";
  app.JarFileName = "C:\\JavaApps\\SampleApp.jar";
  app.WorkFolder = "C:\\JavaApps";
  app.ApplicationArguments = "in data.txt";
  app.Options = "-verbose:class";

  # Launches the Java application
  app.Run();
  # Test the application
  # ...

  app.Close();

VBScript

Sub Test
  ' Add a Java application to the project
  ind = TestedApps.AddJavaApp
  Set app = TestedApps.Items(ind)

  ' Specify Java application's launch parameters
  app.RunAsJar = true
  app.JVMExecutable = "C:\Program Files\Java\jre7\Bin\java.exe"
  app.JarFileName = "C:\JavaApps\SampleApp.jar"
  app.WorkFolder = "C:\JavaApps"
  app.ApplicationArguments = "in data.txt"
  app.Options = "-verbose:class"

  ' Launches the Java application
  app.Run
  ' Test the application
  …

  app.Close
End Sub

DelphiScript

procedure Test();
var ind, app;
begin
  // Add a Java application to the project
  ind := TestedApps.AddJavaApp();
  app := TestedApps.Items(ind);

  // Specify Java application's launch parameters
  app.RunAsJar := true;
  app.JVMExecutable := 'C:\Program Files\Java\jre7\Bin\java.exe';
  app.JarFileName := 'C:\JavaApps\SampleApp.jar';
  app.WorkFolder := 'C:\JavaApps';
  app.ApplicationArguments := 'in data.txt';
  app.Options := '-verbose:class';

  // Launches the Java application
  app.Run;
  // Test the application
  …

  app.Close;
end;

C++Script, C#Script

function Test()
{
  // Add a Java application to the project
  var ind = TestedApps["AddJavaApp"]();
  var app = TestedApps["Items"](ind);

  // Specify Java application's launch parameters
  app["RunAsJar"] = true;
  app["JVMExecutable"] = "C:\\Program Files\\Java\\jre7\\Bin\\java.exe";
  app["JarFileName"] = "C:\\JavaApps\\SampleApp.jar";
  app["WorkFolder"] = "C:\\JavaApps";
  app["ApplicationArguments"] = "in data.txt";
  app["Options"] = "-verbose:class";

  // Launches the Java application
  app["Run"]();
  // Test the application
  …

  app["Close"]();
}

See Also

Testing Java Applications
About Tested Applications
Working With Tested Applications in Tests
TestedApps Object

Highlight search results