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.
Note: The script exits, but the Virtual User keeps running and goes to the next action.
fail(String)
public void fail(String message);
Parameters:
-
message
: The message
Marks the current script as failed and stops the execution of the script. The specified message will be logged at ERROR level.
Note: The script exits, but the Virtual User keeps running and goes to the next action.
fail(String, String)
public void fail(String errorCode,
String message);
Parameters:
-
errorCode
: The error code for the NeoLoad action -
message
: The message
Marks the current script as failed and stops the execution of the script. The specified message will be logged at ERROR level.
Note: The script exits, but the Virtual User keeps running and goes to the next action.
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()
public 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:
-
name
: The name of the proxy, defined in NeoLoad, to retrieve. -
url
: The url that will be fetched with the proxy.
Returns a proxy defined in NeoLoad (identified by name).
getProxyByType(String, String)
public Proxy getProxyByType(String type, String url);
Parameters:
-
type
: The proxy type (INTERNET, APPLICATION or NEOLOAD_WEB). -
url
: The url that will be fetched with the proxy.
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.
stopTest()
public void stopTest();
Stops the current running test with default parameters. The status of the test is FAILED and the stop policy is GRACEFUL.
stopTest(String status)
public void stopTest(String status);
Stops the current running test. The stop policy is GRACEFUL.
Parameters:
-
status
: the status of the test (PASSED or FAILED).
stopTest(String status, String stopPolicy)
public void stopTest(String status, String stopPolicy);
Stops the current running test.
Parameters:
-
status
: the status of the test (PASSED or FAILED). -
stopPolicy
: the stop policy (GRACEFUL or TERMINATE).