RuntimeContext Class

This class represents the execution context of the script.

It is accessible from the pre-defined variable: "context" and should not be created directly.

Example:

 var myvar = context.variableManager.getValue("myvar"); if (myvar==null) { context.fail("Variable 'myvar' is not defined"); }

Synopsis

 public class RuntimeContext {
  // Public Fields
  public LoadGenerator currentLG ;
  public VirtualUser currentVU ;
  public VariableManager variableManager ;
  // Public Methods
  public void fail();
  public void fail(String message);
  public void fail(String errorCode,
                   String message);
  public long getElapsedTime();
  public String getTestStatus();
  public String getProjectName();
  public String getScenarioName();
  public String getTestName();
  public String getTestId();
  public String getAccountToken();
}

currentLG

public LoadGenerator currentLG ;

The Load Generator executing the current Virtual User.

currentVU

public VirtualUser currentVU ;

The Virtual User currently running.

variableManager

public VariableManager variableManager ;

The VariableManager

fail()

public void fail();

Marks the current script as failed and stops the execution of the script. A default error message will be logged at ERROR level.

fail(String)

public void fail(String message);

Parameter

Marks the current script as failed and stops the execution of the script. The specified message will be logged at ERROR level.

fail(String, String)

public void fail(String errorCode,
                 String message);

Parameters

Marks the current script as failed and stops the execution of the script. The specified message will be logged at ERROR level.

getProjectName()

public String getProjectName();

Returns the name of the project currently being executed.

getScenarioName()

public String getScenarioName();

Returns the name of the scenario currently being executed.

getTestName()

public String getTestName();

Returns the name of the test currently being executed.

getTestId()

public String getTestId();

Returns the ID of the test currently being executed.

This identifier can be used to access the test result in NeoLoad Web.

getAccountToken()

public String getAccountToken();

Returns the token configured in the NeoLoad Preferences or the one provided in the command line if any. Returns "null" if the token is not configured in the Preferences nor provided in the command line.

getElapsedTime()

public long getElapsedTime();

Returns the elapsed time in milliseconds since the test started.

getTestStatus()

public String getTestStatus();

Returns the current status of the test. The test state can be "RUNNING" or "STOPPING".

getWebPlatformApiUrl()

publilc String getWebPlatformApiUrl ();

Returns the Rest API URL of NeoLoad Web. Depending on the preferences configuration in NeoLoad (Saas or On-premise), it returns the URL of NeoLoad Web SaaS or on-premise version.



getProxyByName(String, String)

public Proxy getProxyByName(String name, String url);

Parameters

Returns a proxy defined in NeoLoad (identified by name).

getProxyByType(String, String)

public Proxy getProxyByType(String type, String url);

Parameters

Returns a proxy defined in NeoLoad (identified by type).

getWebPlatformFrontUrl()

public String getWebPlatformFrontUrl()

Returns the NeoLoad Web front end url, null if the NeoLoad Web option is disabled.

getWebPlatformRunningTestUrl()

public String getWebPlatformRunningTestUrl()

Returns the Neoload Web front end url of the running test, null if the NeoLoad Web option is disabled.