Members
getContext
Get the environment object of the Testrun object.
Example
// Example: Run test on all connected devices using runDTest and access test context
var { runDTest } = require("sigma/mte");
var devices = Device.searchObject(sigmaConst.DevAll);
var objArr = runDTest('Hello', 'facebook.tpf', 'Testenv.js', 'login', devices);
for (let i = 0; i < objArr.length; i++) {
// Get configuration parameters for each device's test run
print("Device name is: " + objArr[i].getContext().get('device'));
print("Device username is: " + objArr[i].getContext().get('username'));
print("Device password is: " + objArr[i].getContext().get('password'));
}
// Testenv.js content:
define("requireVersion","1.5.0.2865");
define("version","6.5.0.2886");
define("verbose", 0);
define("resolution", "1080*1920");
var { Testrun } = require("sigma/mte");
print ("RUN TEST BEGIN ...");
print("Device name is: " + Testrun.getContext().get('device'));
print("Device username is: " + Testrun.getContext().get('username'));
print("Device password is: " + Testrun.getContext().get('password'));
print("Device message is: " + Testrun.getContext().get('info'));
print ("RUN TEST END!");
getDevice
Get the execution device of the current Testrun object.
Example
var { runDTest } = require("sigma/mte");
// Search for all connected devices
var devices = Device.searchObject(tcConst.DevAll);
// Run test on each device using 'facebook.tpf' and 'Testenv.js'
var objArr = runDTest('Hello', 'facebook.tpf', 'Testenv.js', 'login', devices);
// Wait for tasks to start
delay(1000);
// Output device serial numbers
for (let i = 0; i < objArr.length; i++) {
print("Device SN is: " + objArr[i].getDevice().SN);
}
// Contents of 'Testenv.js':
define("requireVersion","1.5.0.2865");
define("version","6.5.0.2886");
define("verbose",0);
define("resolution","1080*1920");
var { Testrun } = require("sigma/mte");
print("RUN TEST BEGIN ...");
print("Device name is: " + Testrun.getContext().get('device'));
print("Device username is: " + Testrun.getContext().get('username'));
print("Device password is: " + Testrun.getContext().get('password'));
print("Device message is: " + Testrun.getContext().get('info'));
print("RUN TEST END!");
getMessage
Get instant messages for the specified Testrun object.
This message reflects the current execution state of the Testrun,
such as "1:Running" or "0:Stopped", or any custom value set via setMessage().
Example
var { Testrun } = require("sigma/mte");
// Create and run a test run named "Hello"
try {
const testrunObj = new Testrun("Hello", "facebook.tpf", "Testenv.js", "login");
} catch (e) {
print("Error:" + e);
print(lastError());
}
// Get the status message of the test run
var msg = testrunObj.getMessage();
print("Testrun status message: " + msg);
// 'Testenv.js' might include logic like:
define("requireVersion", "1.5.0.2865");
define("version", "6.5.0.2886");
define("verbose", 0);
define("resolution", "1080*1920");
var { Testrun } = require("sigma/mte");
print("RUN TEST BEGIN ...");
print("Device name is: " + Testrun.getContext().get("device"));
print("Device username is: " + Testrun.getContext().get("username"));
print("Device password is: " + Testrun.getContext().get("password"));
print("Device message is: " + Testrun.getContext().get("info"));
print("RUN TEST END!");
// If it executes successfully, `getMessage()` may return:
// "1:Running", "0:Stopped", or any custom message set by the script
getStatus
Get the current execution status of this Testrun instance.
The returned value reflects the current state of the test run, such as:
"1:Running": The test is currently executing.
"0:Stopped": The test has been stopped.
- Custom messages previously set using
setStatus() or setMessage().
This method is useful for monitoring the test progress or result after execution.
Example
var { Testrun } = require("sigma/mte");
// Create a new Testrun instance
try {
const testrunObj = new Testrun("Hello", "facebook.tpf", "Testenv.js", "login");
} catch (e) {
print("Error: " + e);
print(lastError());
}
// Get the status after test starts
var status = testrunObj.getStatus();
print("Current test status: " + status);
// 'Testenv.js' script file content:
define("requireVersion", "1.5.0.2865");
define("version", "6.5.0.2886");
define("verbose", 0);
define("resolution", "1080*1920");
var { Testrun } = require("sigma/mte");
print("RUN TEST BEGIN ...");
print("Device name is: " + Testrun.getContext().get("device"));
print("Device username is: " + Testrun.getContext().get("username"));
print("Device password is: " + Testrun.getContext().get("password"));
print("Device message is: " + Testrun.getContext().get("info"));
print("RUN TEST END!");
// If successful, `getStatus()` may return:
"1:Running", "0:Stopped", or a custom status string
name :string
The name of the test run instance.
This name must be globally unique within the current script execution context.
It is used for task registration, duplicate check, runtime status management, and as an identifier in logs or error messages.
If multiple tests are running in parallel (e.g., via runDTest or runCTest), this name will typically be suffixed (e.g., Hello0, Hello1, ...).
Type:
Example
var testrun = new Testrun("Hello007", "mte.tpf", "sample.js", "qqmusic");
print("Testrun name is: " + testrun.name); // Output: Hello007
setMessage
Set up an instant message for the specified Testrun object.
Example
var { Testrun } = require("sigma/mte");
// Create a new Testrun instance
try {
const testrunObj = new Testrun("Hello", "facebook.tpf", "Testenv.js", "login");
} catch (e) {
print("Error: " + e);
print(lastError());
}
// Set a custom status or message for this run
testrunObj.setMessage("Testmessage");
// Later, you can retrieve this message using:
print(testrunObj.getMessage());
// 'Testenv.js' file content:
define("requireVersion", "1.5.0.2865");
define("version", "6.5.0.2886");
define("verbose", 0);
define("resolution", "1080*1920");
var { Testrun } = require("sigma/mte");
print("RUN TEST BEGIN ...");
print("Device name is: " + Testrun.getContext().get("device"));
print("Device username is: " + Testrun.getContext().get("username"));
print("Device password is: " + Testrun.getContext().get("password"));
print("Device message is: " + Testrun.getContext().get("info"));
print("RUN TEST END!");
setStatus
Set up an instant status message for the specified Testrun object.
Example
var { Testrun } = require("sigma/mte");
// Create a Testrun instance for the 'login' config in 'facebook.tpf'
try {
const testrunObj = new Testrun("Hello", "facebook.tpf", "Testenv.js", "login");
} catch (e) {
print("Error: " + e);
print(lastError());
}
// Set a test status or description message
testrunObj.setStatus("TestMessage1");
// Later, retrieve the status
print(testrunObj.getStatus()); // Output: TestMessage1
// 'Testenv.js' script content:
define("requireVersion", "1.5.0.2865");
define("version", "6.5.0.2886");
define("verbose", 0);
define("resolution", "1080*1920");
var { Testrun } = require("sigma/mte");
print("RUN TEST BEGIN ...");
print("Device name is: " + Testrun.getContext().get("device"));
print("Device username is: " + Testrun.getContext().get("username"));
print("Device password is: " + Testrun.getContext().get("password"));
print("Device message is: " + Testrun.getContext().get("info"));
print("RUN TEST END!");
stop
Stops the currently running test script associated with this Testrun instance.
This method attempts to terminate the script process and update its internal status message.
If the script is already stopped or not found, it will return false and log an error via lastError().
Example
// Example: Execute a Testrun and stop it via instance method
var { Testrun } = require("sigma/mte");
try {
// Create a new Testrun instance using 'facebook.tpf' and run 'Testenv.js'
const testrunObj = new Testrun('Hello', 'facebook.tpf', 'Testenv.js', 'login');
// Stop the Testrun by calling the instance method
testrunObj.stop();
} catch (e) {
print("Error: " + e);
print(lastError());
}
// Set custom status after stopping
testrunObj.setStatus('TestMessage1');
// Testenv.js script example:
define("requireVersion","1.5.0.2865");
define("version","6.5.0.2886");
define("verbose",0);
define("resolution","1080*1920");
var { Testrun } = require("sigma/mte");
print("RUN TEST BEGIN ...");
print("Device name is: " + Testrun.getContext().get('device'));
print("Device username is: " + Testrun.getContext().get('username'));
print("Device password is: " + Testrun.getContext().get('password'));
print("Device message is: " + Testrun.getContext().get('info'));
print("RUN TEST END!");