Description
The AddJavaApp
method allows you to dynamically add a Java tested application to your test project.
Declaration
TestedApps.AddJavaApp()
Result | Integer |
Applies To
The method is applied to the following object:
Result Value
The zero-based index of the Java application in the Tested Applications collection. You can use this index to access the corresponding JavaTestedApp
object by using the TestedApps.Items(Index)
property.
Example
The following script adds a Java application to the TestedApps collection and launches it.
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
Adding Java and JavaFX Applications to the List of Tested Applications