虽然许多测试是自包含的,但是存在在外部完成配置的情况,例如通过驱动测试执行的调度器,例如连续积分服务器。在这些情况下,squishrunner 可执行文件可用于将参数传递给测试脚本。测试脚本可以访问这些参数并根据值采用其行为。


The squishrunner option that supports this is called --scriptargs. It has to be specified at the very end of the complete squishrunner command call. All arguments which are specified after --scriptargs are passed to the executed script.

The following example shows a squishrunner call that passes two arguments to the test script:

./squishrunner --testsuite /path/to/suite --testcase tst_case1 --reportgen xml3.2,/path/to/result --scriptargs argument1 argument2

Accessing these arguments in the test script depends on the scripting language that is used. Assuming that Python is used, we need to use the sys module which provides a list of command line arguments through the argv variable. The following snippet shows how to log all arguments to the Squish Test Result. Visit the Squish documentation to learn 如何访问JavaScript测试脚本中的参数。

import sys
def main():
    test.log('Number of arguments:' + str(len(sys.argv)) + 'arguments.')
    test.log('Argument List: ' + str(sys.argv))

When executing the snippet above, you will notice that the first field, argv[0], holds the name of the script itself. This is common practice in many scripting languages. The first argument we pass to the squishrunner --scriptargs option can be accessed through argv[1].


让’返回到最初的示例之一:我们希望通过程序参数来配置AUT。让’s assume this argument is called --nolauncher --autoconnect. The command for such an application startup could look like this:

./exampleApplication --nolauncher --autoconnect

To pass these arguments to the test script, the squishrunner call would look like this:

./squishrunner --testsuite /path/to/suite --testcase tst_case1 --reportgen xml3.2,/Users/flo/tmp/result --scriptargs --nolauncher --autoconnect

Finally, we need to access the arguments in the test script itself, and pass it to the startApplication call:

import names
import sys

def main():
    autCommand = "exampleApplication"
    for i in range(1, len(sys.argv)):
        autCommand = autCommand + " " + sys.argv[i]





您的电子邮件地址不会被公开。 必需的地方已做标记 *