VS Code#

The instructions below are for setting up an stb-tester development environment on your Windows PC, but it’s the same process on MacOS or Linux.

Install Python 3.10#

Download the Python 3.10 Windows installer from: https://www.python.org/downloads/release/python-3109/. You’ll want “Windows installer (64-bit)”. Run it to install.

We want 3.10 specifically, so that it matches the version of Python on the Stb-tester Node.

You can install Python 3.10 alongside any other Python versions you have; they shouldn’t interfere with each other.

Install Git#

Go to https://git-scm.com and download the installer for the latest release.

Run the installer to install git.

Most of the default settings are fine. The exceptions are:

  • At the dialog “Choosing the default editor used by Git”, choose your preferred text editor.

  • At the dialog “Choosing HTTPS transport backend”, select “Use the native Windows Secure Channel library”.

Install VS Code#

Download the installer from https://code.visualstudio.com.

Run the installer to install VS Code.

Install VS Code extensions#

Install the Python and Run on Save extensions. In VS Code, press Ctrl-P and paste these commands (one line at a time):

ext install ms-python.python
ext install pucelle.run-on-save

Clone the test-pack repository#

Go to your Stb-tester Portal. In the “Automated tests” tab, copy the test-pack URL (it will look like https://github.com/stb-tester/stb-tester-test-pack-yourcompanyname).

In VS Code, click “clone repository” and paste the test-pack URL.

You should see a “Connect to GitHub” dialog box, which will open a login page in your browser. Once you have logged in, your test-pack will then be cloned to your local machine.

At the dialog “Would you like to open the cloned repository?”, select “Open”.

At the dialog “Do you trust the authors of the files in this folder?”, select “Yes, I trust the authors”.

Configure VS Code and venv#

In VS Code, start a new terminal and run this command:

py stbt_rig.py setup --vscode

This will create a Python virtual environment (in a directory called .venv) with the stbt APIs and dependencies installed. It will also configure VS Code to enable pylint checks, a button to run tests from the IDE, and syncing a git snapshot to the Stb-tester Portal whenever you press “Save”.

When VS Code says “We noticed a new environment has been created. Do you want to select it for the workspace folder?”, click “Yes”.

Test that it’s all working#

  1. Try running a test from within VS Code — we should see it running in the portal.

  2. We should see stbt-specific linting in place, so let’s introduce an error deliberately.

  3. git snapshot on save should be working, so we can see it in action with the Object Repository.

Troubleshooting#

Make sure you have the latest version of stbt_rig.py. You can update the stbt_rig.py in your test-pack by downloading the latest version from https://github.com/stb-tester/stbt-rig.

Then re-run py stbt_rig.py setup --vscode.

If VS Code still can’t find the stbt APIs, make sure that VS Code is using the same virtualenv that stbt_rig created (that is, a folder called .venv in your test-pack checkout). Open the Command Palette (Control + Shift + P), type “Python: Select Interpreter”, and select the Python from .venv/bin/python:

_images/python-interpreter.png

If your Access Token for the Stb-tester Portal has changed, re-run py stbt_rig.py setup --vscode; it will ask you to enter your new Access Token.