IDE Configuration

IntelliSense for stbt APIs

Install the “stb-tester” package using pip:

pip install stb-tester

Note

This package doesn’t include video-capture infrastructure and other complex dependencies, so it won’t allow you to run your test scripts locally (on your PC). It does enable your IDE’s “IntelliSense” or “Code Insight” features such as code completion, type inference, inline documentation, and linting.

If you haven’t yet upgraded your test-pack to use the latest stbt version, you can tell pip to install a specific version like this:

pip install stb-tester~=31.0

Note that ~=31.0 will install the latest 31 package, but not 32 or greater.

Make sure you install the same version locally as the version specified in your test-pack’s configuration file (see test_pack.stbt_version in the Configuration Reference). The stb-tester pip package is only available for version 31 and newer.

Sync the code from your IDE to the Stb-tester portal

Bind the “Save” button of your IDE to run python stbt_rig.py snapshot after saving. This will push your local code to the Stb-tester Portal on a branch called “<your username>/snapshot” — without affecting your local git checkout.

(After you have tested your changes & got them working, you still need to do “git commit” and “git push” to make it official. See Development Workflow.)

Before setting this up in your IDE, make sure that you can run python stbt_rig.py snapshot from your terminal, to debug any authentication issues. See stbt-rig installation and stbt-rig authentication here.

PyCharm

In Preferences > Plugins install the File Watchers plugin.

Now in Preferences > Tools > File Watchers add a new watcher with the following settings:

  • Name: stbt_rig.py snapshot
  • File type: Any
  • Scope: Project Files
  • Program: python
  • Arguments: stbt_rig.py snapshot
  • Working directory: path to your test-pack checkout
images/file-watchers-configuration.png

Run a test from your IDE

Eclipse

In External Tools Configurations add a new tool of type Program with the following settings (changing “stb-tester-e5a091e40de1” in the fields below to the actual ID of your Stb-tester node):

  • Name: Run selected test on stb-tester-e5a091e40de1
  • Location: ${project_loc}/stbt_rig.py
  • Working Directory: ${project_loc}
  • Arguments: -v --node-id=stb-tester-e5a091e40de1 run tests/${selected_resource_name}::${selected_text}

Now you can double-click on the name of a test and click the “Run” button. This will automatically take a snapshot of your code and submit it to the Stb-tester portal (you don’t need to do a git commit first). The logs from the test will appear in the IDE’s console:

images/run-test.png

For more details about stbt_rig.py see Development Workflow.

The arguments above assume that the authorization token for the Stb-tester portal is already in your system keyring. You can set this up by running stbt_rig.py manually first, from your terminal. If that doesn’t work you can save your token to a file and add --portal-auth-file FILENAME to the arguments in the configuration above.

PyCharm

Go to Run > Edit Configurations and select Templates > Python tests > pytest. Fill in the following settings (changing “stb-tester-e5a091e40de1” in the fields below to the actual ID of your Stb-tester node):

  • Additional Arguments: --node-id=stb-tester-e5a091e40de1 -p no:python -p stbt_rig
  • Add content roots to PYTHONPATH: True

The configuration should now look like:

images/configuration.png

You can now run the current test with Ctrl-Shift-F10 or by clicking the green play button in the margin on the left and selecting “Run ‘pytest for …’”:

images/run-test1.png

For more details about stbt_rig.py see Development Workflow.

The arguments above assume that the authorization token for the Stb-tester portal is already in your system keyring. You can set this up by running stbt_rig.py manually first, from your terminal. If that doesn’t work you can save your token to a file and add --portal-auth-file FILENAME to the arguments in the configuration above.