Passing arguments to test scripts

Last edited on

Overview

To pass arguments to test scripts there are two basic approaches:

Examples

Setting environment variable and starting squishrunner

export TEST_CASE_MESSAGE=Hello world!
squishrunner --testsuite suite_my_test_suite
In Unix shells (Linux, OS X, etc.)
set TEST_CASE_MESSAGE=Hello world!
squishrunner --testsuite suite_my_test_suite
On Windows (in cmd.exe)

Reading environment variable in JavaScript test scripts

function main() {
    // Read our environment variable:
    var msg = OS.getenv("TEST_CASE_MESSAGE");
    test.log("Test case message: " + msg);
}
test.js

Reading environment variable in Python test scripts

import os

def main():
    # Read our environment variable:
    msg = os.environ["TEST_CASE_MESSAGE"]
    test.log("Test case message: " + msg)
test.py

Passing data between test cases only possible via files

To pass data from one test case to another environment variables cannot be used (because each test case is executed by a new squishrunner instance which does not see any of the environment variables which have been set in a previous squishrunner instance).

So typically one would write the data to files in one test script and read them in the next test case's script.