Global Scripts

The Global Scripts view is shown in the Test Management Perspective.

Any test case in any test suite can access global scripts. You can add and remove global scripts and global script folders in the Global Scripts view or in global script wizard (File > New > Squish Global Script File).

Note: Global scripts are an advanced feature. They are not recommended for new Squish users, and even experienced users should use them with care. Changing or deleting functionality in a global script (or sometimes even adding it) will affect every test case in every test suite that uses the global script. Therefore, we recommend that you place global scripts under version control.

{}

The Global Scripts view

By default, this view is shown beside the Editor view, but you can drag it elsewhere. For example, to a new tab beside the Test Summary view.

The first time you open the view, all its toolbar buttons are disabled because global scripts folders do not exist, yet. Right-click the view to open a context menu and select Add > Global Script Directory. In the Select Folder dialog, select or create a folder for storing global scripts. You can store global scripts in several folders.

To create globally shared script files, select Add > File or use the New Scriptfile toolbar button. New script files are called script_1.py, and so on, using the appropriate scripting language extension. You can rename them when you create them or at any time by selecting Rename in the context menu. Click the filename to open an Editor view for editing the file. To delete script files, click their name in the view and select Delete in the context menu or on the toolbar. However, keep in mind that the scripts may be used by many test cases in many test suites.

You can access global scripts in the same way as local scripts. For example, you can make the contents of a global script called global.py available to the test case script in the usual way:

source(findFile("scripts", "global.py"));

This statement uses the String findFile(where, filename) function to get the script's full name including its path and the source(filename) function to evaluate the script and make its classes, functions, and variables accessible to the test case script.

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.
The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.
Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.