Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

How to Run and Debug TruWeb Scripts Using Visual Studio Code

Micro Focus Contributor
Micro Focus Contributor
1 0 1,722

Guest blog post by
Yafim Kazak

Visual Studio Code is an open-source, cross-platform code editor developed by Microsoft™. It includes support for debugging, Git, code completion, snippets, code refactoring, etc.

Now you can leverage VS Code to write performance testing scripts using TruWeb, Micro Focus's latest cutting-edge tool for web protocol performance and load testing. TruWeb is lightweight, scalable, cross-platform and easily deployed.

Follow the steps below to start using Visual Studio Code to edit, run, and debug your TruWeb scripts.

This article assumes prior familiarity with Visual Studio Code.

Installation and prerequisites:

  1. Visual Studio Code installed.
  2. TruWeb installed and configured. See detailed instructions here
  3. “Node debug” (by Microsoft) an extension of Visual Studio Code (usually installed automatically).
    If “Node debug” was not installed automatically, follow these steps to install it:
    a. Click Extensions.
    b. Search for Node Debug or go to: https://marketplace.visualstudio.com/items?itemName=ms-vscode.node-debug2 
    c. Click Install
    d. After the installation is complete, restart Visual Studio Code.

Part 1 – Enable autocomplete and intellisense capabilities for TruWeb script:

Intellisense will be enabled once the file “TruWebSdk.d.ts” is placed in the script folder.  You can get it from one of the following sources:

  1. Copy it from any of the scripts in the examples folder in the TruWeb.
  2. Fetch the one located in our empty script template GitHub repository. Note that if you are not using the latest version of TruWeb, it might not fit perfectly.

Place the “TruWebSdk.d.ts” file in your script folder.

Part 2 – How to add a task to run a TruWeb script:

You will now add a new task to your “tasks.json” file to run TruWeb in one of its supported modes: single, load, or debu­­g.

  1. Open the script folder you would like to run (for testing, you can copy the empty script located under the examples folder or download the empty script template from our GitHub repository).
  2. Press “Ctrl+Shift+p” (“Cmd+Shift+p” on macOS). In the opened dropdown, type “configure task” and select it from the dropdown. Select “create tasks.json from file template”. Alternatively, Click on the “terminal” menu item, select “Configure task”.
  3. A list of task templates are displayed in a dropdown. Select others.

A basic default task template is created, similar to the one in the picture below:

  1.  Change the following parameters to their relevant values:

    • “label” – A name for this task. For example: “TruWeb Single Run”.
    • “type” – Should be “process”.
    • “command” – The path to the TruWeb executable. In this example it's: ${env:TRUWEB_PATH}\\TruWeb.exe (Don't forget escaping slashes for your path on Windows). The example file shows how to configure cross platform script.
    • “args” – An array for the argument, each item should be separated by a comma.
      i. The first item should signal TruWeb that it’s being run from vscode – “-ide=vscode”.
      ii. Second item is optional and relevant only in case you’d like to run load or debug from vscode. Should be:
      1. “-mode=load” in case you’d like to run in load mode.
      2. “-inspect” in case you’d like to run in debug mode.

  iii. Third item is mandatory. Should point to the script folder you’d like to run. In case, you’ve opened up the script as folder (as these instructions pointed), you can simply add “${cwd}”. Otherwise, you can add the path to the script folder (e.g. “C:\\Scripts\\AdvantageOnlineShopping”).

  (See part 3 for additional configuration.)

default 2.png

In the image above, you can see a basic “tasks.json” that enables the running of different modes of TruWeb straight from VS Code on windows (the attached example includes cross platform fit “tasks.json”).

  1. Use one of the following methods to run the TruWeb script:
      • Click Terminal (in older versions of VS Code, click Tasks) and select Run task., then select the relevant task.
      • Press “Ctrl+Shift+p” (“Cmd+Shift+p” on macOS) and type “Run task”. Select the relevant task from the dropdown.



  2. If any errors were discovered during the run you can press “ctrl” (cmd on macOS) + left mouse button to jump to the line where the error occurred.d4.png
  3. If you would like to clear the terminal before each run, add the following property to the task config - "presentation": {"panel": "new"} d5.png


The attached TruWeb script example includes additional example on how to create cross platform “tasks.json” which depends on using the “TRUWEB_PATH” environment variable. 

Part 3 – Debug the TruWeb Script:

You will now add an additional file that will enable you to run a TruWeb script and debug it.

  1. Press “Ctrl+Shift+p” (“Cmd+Shift+p” on macOS), type “Debug: open launch.json” and select the corresponding item from the dropdown (the file json will be created automatically if it doesn’t exist).
    Alternatively, you can click Debug on the toolbar and select Add configurations. 
  2. Now add the following to your json in the configurations array: d6.PNG
    Note that the “preLaunchTask” field must match the “label” field of the defined debug task in the tasks.json file (in this example, it was labeled “TruWeb Debug Run”).
  3. You will now add a property to your tasks.json, to allow the VS Code debugger to connect to the TruWeb script when the script is run.
  • Open json (it is in the .vscode directory inside the script directory)
  • Go to the debug task (in our example, it was labeled “TruWeb Debug Run”).
  • Add the property – “isBackground”: true

For example:



 That’s it! Press F5 to run the script.


 Note: A pop up might appear with a “task cannot be tracked” error message – just click “debug anyway”. d9.png




The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.